Orange: tuesday sync with bf-blender
authorTon Roosendaal <ton@blender.org>
Tue, 6 Dec 2005 10:58:54 +0000 (10:58 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 6 Dec 2005 10:58:54 +0000 (10:58 +0000)
124 files changed:
intern/bmfont/intern/BMF_BitmapFont.cpp
intern/boolop/intern/BOP_Face2Face.cpp
intern/boolop/intern/BOP_Interface.cpp
intern/boolop/intern/BOP_Mesh.cpp
intern/boolop/intern/BOP_Mesh.h
intern/bsp/intern/CSG_BooleanOps.cpp
intern/elbeem/SConscript
intern/elbeem/intern/blenderdummy.cpp
intern/elbeem/make/msvc_6_0/elbeem.dsp
intern/elbeem/make/msvc_7_0/elbeem.vcproj
intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/opennl/extern/ONL_opennl.h
intern/opennl/intern/opennl.c
projectfiles/blender/imbuf/BL_imbuf.dsp
projectfiles_vc7/blender/blender.vcproj
projectfiles_vc7/blender/imbuf/BL_imbuf.vcproj
release/Makefile
release/scripts/bevel_center.py
release/scripts/bvh_import.py
release/scripts/console.py
release/scripts/lightwave_import.py
release/scripts/uv_export.py
source/blender/blenkernel/BKE_anim.h
source/blender/blenkernel/BKE_bad_level_calls.h
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/BKE_group.h
source/blender/blenkernel/BKE_material.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_utildefines.h
source/blender/blenkernel/bad_level_call_stubs/stubs.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/include/BDR_unwrapper.h
source/blender/include/BIF_editgroup.h
source/blender/include/BIF_meshtools.h
source/blender/include/BIF_resources.h
source/blender/include/BIF_space.h
source/blender/include/blendef.h
source/blender/include/butspace.h
source/blender/include/transform.h
source/blender/makesdna/DNA_effect_types.h
source/blender/makesdna/DNA_group_types.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_world_types.h
source/blender/render/extern/include/render.h
source/blender/render/extern/include/render_types.h
source/blender/render/intern/include/pixelshading.h
source/blender/render/intern/include/rendercore.h
source/blender/render/intern/include/texture.h
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/ray.c
source/blender/render/intern/source/renderPreAndPost.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/renderdatabase.c
source/blender/render/intern/source/texture.c
source/blender/render/intern/source/vanillaRenderPipe.c
source/blender/render/intern/source/zbuf.c
source/blender/renderconverter/intern/convertBlenderScene.c
source/blender/src/SConscript
source/blender/src/butspace.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_object.c
source/blender/src/buttons_shading.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/editgroup.c
source/blender/src/editipo.c
source/blender/src/editmesh.c
source/blender/src/editmesh_mods.c
source/blender/src/editobject.c
source/blender/src/editscreen.c
source/blender/src/editview.c
source/blender/src/filesel.c
source/blender/src/header_buttonswin.c
source/blender/src/header_image.c
source/blender/src/header_oops.c
source/blender/src/header_view3d.c
source/blender/src/headerbuttons.c
source/blender/src/interface_panel.c
source/blender/src/meshtools.c
source/blender/src/outliner.c
source/blender/src/parametrizer.c [new file with mode: 0644]
source/blender/src/parametrizer.h [new file with mode: 0644]
source/blender/src/parametrizer_intern.h [new file with mode: 0644]
source/blender/src/previewrender.c
source/blender/src/space.c
source/blender/src/transform_conversions.c
source/blender/src/transform_generics.c
source/blender/src/unwrapper.c
source/gameengine/Expressions/KX_HashedPtr.cpp
source/gameengine/Expressions/KX_HashedPtr.h
source/gameengine/Ketsji/KX_CameraIpoSGController.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_IPO_SGController.cpp
source/gameengine/Ketsji/KX_LightIpoSGController.cpp
source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Ketsji/KX_WorldIpoController.cpp
source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
source/kernel/gen_system/GEN_HashedPtr.cpp
source/kernel/gen_system/GEN_HashedPtr.h
source/nan_definitions.mk
tools/scons/bs/bs_dirs.py

index 7997a94344b93d0f0df68f2bdd9bde38fda6c811..bbba2c978dd71597ab4d6568bb089b87e17af3c5 100644 (file)
 #include "BMF_BitmapFont.h"
 
 
-#ifdef __APPLE__        
-#include <stdio.h>
-
-static int needs_nvidia_rasterpos_workaround(void)
-{
-       static int well_is_it= -1;
-       
-       if (well_is_it==-1)
-       {
-               well_is_it= (strncmp((char *)glGetString(GL_RENDERER), "NVIDIA GeForce 6800", 18) == 0);
-               if ( well_is_it != 0)
-               {
-                       const GLubyte* vers = glGetString(GL_VERSION);
-                       const GLubyte* v = vers;
-                       int major = 0, minor = 0, sub = 0;
-                       
-                       //advance to the '-'
-                       while ((*v != 0) && (*v!='-'))
-                               v++;
-                       
-                       if (*v == '-')
-                       {
-                               int i = 0;
-                               v++;
-                               
-                               while ((v[i] <= '9') && (v[i] >= '0'))
-                               {
-                                       major *=10;
-                                       major += v[i]-'0';
-                                       i++;
-                               }
-                               
-                               if (v[i] == '.')
-                               {
-                                       i++;
-                                       while ((v[i] <= '9') && (v[i] >= '0'))
-                                       {
-                                               minor *=10;
-                                               minor += v[i]-'0';
-                                               i++;
-                                       }
-                               }
-                               else
-                                       major = -1;
-                               
-                               if (v[i] == '.')
-                               {
-                                       i++;
-                                       while ((v[i] <= '9') && (v[i] >= '0'))
-                                       {
-                                               sub *=10;
-                                               sub += v[i]-'0';
-                                               i++;
-                                       }
-                               }
-                               else
-                                       minor = -1;
-                       }
-
-                       //OS X 10.4.3 is the first version that contained the fix for this problem
-                       // and the 6800's driver version in it is 1.4.16.  So anything after that
-                       // doesn't need the workaround
-
-                       if ( (major == -1) || (minor == -1))
-                       //If anything went wrong don't do the workaround
-                       //
-                               well_is_it = 0;
-                       else if ( (major <= 1) && (minor <= 4) && (sub < 16))
-                               well_is_it = 1;
-                       else
-                               well_is_it = 0;
-               }       
-       }
-
-       return well_is_it;
-}
-
-
-#endif
-
 BMF_BitmapFont::BMF_BitmapFont(BMF_FontData* fontData)
 : m_fontData(fontData)
 {
@@ -154,19 +74,7 @@ void BMF_BitmapFont::DrawString(char* str)
        GLint alignment;
        unsigned char c;
 
-#ifdef __APPLE__        
-     GLint vp[4];  // hack stuff        
-     GLubyte nullm = 0;      // hack stuff      
-        
-     if(needs_nvidia_rasterpos_workaround()) {  // was is_a_really_crappy_nvidia_card()
-             glGetIntegerv(GL_VIEWPORT, vp);   // hack stuff    
-        
-             glBitmap(1, 1, 0, 0, -vp[0], vp[1], &nullm);       
-        
-         }      
- #endif
-       glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+       glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        
        while ( (c = (unsigned char) *str++) ) {
index bdd3637a5986bcbe0c918a1eb115874a245cf1c2..08928935f33da85c5869a70a4687746dc3c4ad26 100644 (file)
@@ -146,7 +146,7 @@ void BOP_mergeVertexs(BOP_Mesh *mesh, unsigned int firstFace);
  * @param facesB set of faces from object B
  */
 void BOP_Face2Face(BOP_Mesh *mesh, BOP_Faces *facesA, BOP_Faces *facesB)
-{
+{              
        for(unsigned int idxFaceA=0;idxFaceA<facesA->size();idxFaceA++) {
                BOP_Face *faceA = (*facesA)[idxFaceA];
                MT_Plane3 planeA = faceA->getPlane();
@@ -160,28 +160,28 @@ void BOP_Face2Face(BOP_Mesh *mesh, BOP_Faces *facesA, BOP_Faces *facesB)
                        idxFaceB<facesB->size() && (faceA->getTAG() != BROKEN) && (faceA->getTAG() != PHANTOM);) {
                        BOP_Face *faceB = (*facesB)[idxFaceB];
                        if ((faceB->getTAG() != BROKEN) && (faceB->getTAG() != PHANTOM)) {
-                               BOP_BBox boxB(mesh->getVertex(faceB->getVertex(0))->getPoint(),
-                                                         mesh->getVertex(faceB->getVertex(1))->getPoint(),
-                                                         mesh->getVertex(faceB->getVertex(2))->getPoint());
-                               if (boxA.intersect(boxB)) {
+                         BOP_BBox boxB(mesh->getVertex(faceB->getVertex(0))->getPoint(),
+                                       mesh->getVertex(faceB->getVertex(1))->getPoint(),
+                                       mesh->getVertex(faceB->getVertex(2))->getPoint());
+                         if (boxA.intersect(boxB)) {
 
-                                       MT_Plane3 planeB = faceB->getPlane();
-                                       if (BOP_containsPoint(planeB,p1) && 
-                                               BOP_containsPoint(planeB,p2) && 
-                                               BOP_containsPoint(planeB,p3)) {
-                                               if (BOP_orientation(planeB,planeA)>0) {
-                                                       BOP_intersectCoplanarFaces(mesh,facesB,faceA,faceB,false);
-                                               }
-                                       }
-                                       else {
-                                               BOP_intersectNonCoplanarFaces(mesh,facesA,facesB,faceA,faceB);
-                                       }
-                               }                         
+                           MT_Plane3 planeB = faceB->getPlane();
+                           if (BOP_containsPoint(planeB,p1) && 
+                               BOP_containsPoint(planeB,p2) && 
+                               BOP_containsPoint(planeB,p3)) {
+                             if (BOP_orientation(planeB,planeA)>0) {
+                               BOP_intersectCoplanarFaces(mesh,facesB,faceA,faceB,false);
+                             }
+                           }
+                           else {
+                             BOP_intersectNonCoplanarFaces(mesh,facesA,facesB,faceA,faceB);
+                           }
+                         }                       
                        }
                        if (faceB->getTAG()==BROKEN){
-                               facesB->erase(facesB->begin()+idxFaceB);
+                         facesB->erase(facesB->begin()+idxFaceB);
                        }else
-                               idxFaceB++;
+                         idxFaceB++;
                }
        }
        
index 1ef394963ac03387033464336286ff408c2ef6f6..02945340d55e25dd34c0405a764e154955b1597f 100644 (file)
@@ -92,9 +92,9 @@ BoolOpState BOP_performBooleanOperation(BoolOpType                    opType,
                                                                                CSG_VertexIteratorDescriptor  obBVertices,
                                                                                CSG_InterpolateUserFaceVertexDataFunc interpFunc)
 {
-#ifdef DEBUG
+       #ifdef DEBUG
        cout << "BEGIN BOP_performBooleanOperation" << endl;
-#endif
+       #endif
 
        // Set invert flags depending on boolean operation type:
        // INTERSECTION: A^B = and(A,B)
@@ -121,9 +121,6 @@ BoolOpState BOP_performBooleanOperation(BoolOpType                    opType,
        // Add B-mesh into C-mesh
        BOP_addMesh(&meshC, &meshBFacesId, &materials, obBProps, obBFaces, obBVertices, invertMeshB);
 
-       if (!meshC.isClosedMesh())
-               return BOP_NO_SOLID;
-
        // Perform the intersection boolean operation.
        BoolOpState result = BOP_intersectionBoolOp(&meshC, &meshAFacesId, &meshBFacesId, 
                                                                                                invertMeshA, invertMeshB);
@@ -131,9 +128,9 @@ BoolOpState BOP_performBooleanOperation(BoolOpType                    opType,
        // Invert the output mesh if is required
        *outputMesh = BOP_exportMesh(&meshC, &materials, outputProps, invertMeshC);
 
-#ifdef DEBUG
+       #ifdef DEBUG
        cout << "END BOP_performBooleanOperation" << endl;
-#endif
+       #endif
        
        return result;
 }
@@ -154,13 +151,13 @@ BoolOpState BOP_intersectionBoolOp(BOP_Mesh*  meshC,
                                                                   bool       invertMeshA,
                                                                   bool       invertMeshB)
 {
-#ifdef DEBUG
+       #ifdef DEBUG
        BOP_Chrono chrono;
        float t = 0.0f;
        float c = 0.0f;
        chrono.start();  
        cout << "---" << endl;
-#endif
+       #endif
 
        // Create BSPs trees for mesh A & B
        BOP_BSPTree bspA;
@@ -171,10 +168,10 @@ BoolOpState BOP_intersectionBoolOp(BOP_Mesh*  meshC,
        bspB.addMesh(meshC, *facesB);
        bspB.computeBox();
        
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "Create BSP     " << c << endl; 
-#endif
+       #endif
 
        unsigned int numVertices = meshC->getNumVertexs();
        
@@ -187,54 +184,54 @@ BoolOpState BOP_intersectionBoolOp(BOP_Mesh*  meshC,
        if ((0.25*facesB->size()) > bspA.getDeep())
          BOP_meshFilter(meshC, facesB, &bspA);
        
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "mesh Filter    " << c << endl; 
-#endif
+       #endif
 
        // Face 2 Face
        BOP_Face2Face(meshC,facesA,facesB);
 
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "Face2Face      " << c << endl;
-#endif
+       #endif
 
        // BSP classification
        BOP_meshClassify(meshC,facesA,&bspB);
        BOP_meshClassify(meshC,facesB,&bspA);
        
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "Classification " << c << endl;
-#endif
+       #endif
        
        // Process overlapped faces
        BOP_removeOverlappedFaces(meshC,facesA,facesB);
        
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "Remove overlap " << c << endl;
-#endif
+       #endif
 
        // Sew two meshes
        BOP_sew(meshC,facesA,facesB);
 
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "Sew            " << c << endl;
-#endif
+       #endif
 
        // Merge faces
        BOP_Merge::getInstance().mergeFaces(meshC,numVertices);
 
-#ifdef DEBUG
+       #ifdef DEBUG
        c = chrono.stamp(); t += c;
        cout << "Merge faces    " << c << endl;
        cout << "Total          " << t << endl;
        // Test integrity
        meshC->testMesh();
-#endif
+       #endif
        
        return BOP_OK;
 }
index a7e7ef61e435e2fa2d84942187eb1ed2b73db347..24d5b3fb6a90b64df4cadd8865750a8ab36d99b8 100644 (file)
@@ -553,23 +553,6 @@ BOP_Index BOP_Mesh::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex)
        return newIndex;
 }
 
-bool BOP_Mesh::isClosedMesh()
-{
-       for(unsigned int i=0; i<m_edges.size(); i++) {
-               BOP_Edge *edge = m_edges[i];
-               BOP_Indexs faces = edge->getFaces();
-               unsigned int count = 0;
-               const BOP_IT_Indexs facesEnd = faces.end();
-               for(BOP_IT_Indexs it = faces.begin();it!=facesEnd;it++) {
-                       if (m_faces[*it]->getTAG()!=BROKEN)
-                               count++;
-               }
-
-               if ((count%2)!=0) return false;
-       }
-
-       return true;
-}
 
 
 /** ***************************************************************************
index adc92c915594e9d50523b4173257fdc89ea6c258..6751df7c4e76058f12db0be546c4111acd447290 100644 (file)
@@ -82,7 +82,6 @@ public:
        unsigned int getNumVertexs(BOP_TAG tag);
        unsigned int getNumFaces(BOP_TAG tag);
        BOP_Index replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex);
-       bool isClosedMesh();
        
        // Debug functions
        void print();
index a677c9c6e94a9029e43a382a510f52ff4c99efec..6c9fecd88e14feb7703b5061cf10b350ae5b7757 100755 (executable)
@@ -103,15 +103,15 @@ CSG_DescibeOperands(
 /**
  * Compute the boolean operation, UNION, INTERSECION or DIFFERENCE
  */
-int
+       int
 CSG_PerformBooleanOperation(
-                                                       CSG_BooleanOperation                 *operation,
-                                                       CSG_OperationType                     op_type,
-                                                       CSG_FaceIteratorDescriptor            obAFaces,
-                                                       CSG_VertexIteratorDescriptor          obAVertices,
-                                                       CSG_FaceIteratorDescriptor            obBFaces,
-                                                       CSG_VertexIteratorDescriptor          obBVertices,
-                                                       CSG_InterpolateUserFaceVertexDataFunc interp_func
+       CSG_BooleanOperation                 *operation,
+       CSG_OperationType                     op_type,
+       CSG_FaceIteratorDescriptor            obAFaces,
+       CSG_VertexIteratorDescriptor          obAVertices,
+       CSG_FaceIteratorDescriptor            obBFaces,
+       CSG_VertexIteratorDescriptor          obBVertices,
+       CSG_InterpolateUserFaceVertexDataFunc interp_func
 ){
        if (operation == NULL) return 0;
        BSP_MeshInfo * mesh_info = static_cast<BSP_MeshInfo *>(operation->CSG_info);
@@ -128,39 +128,33 @@ CSG_PerformBooleanOperation(
        
        switch( op_type ) {
        case e_csg_union:
-               boolType = BOP_UNION;
-               break;
+         boolType = BOP_UNION;
+         break;
        case e_csg_difference:
-               boolType = BOP_DIFFERENCE;
-               break;
+         boolType = BOP_DIFFERENCE;
+         break;
        default:
-               boolType = BOP_INTERSECTION;
-               break;
+         boolType = BOP_INTERSECTION;
+         break;
        }
 
-       BoolOpState boolOpResult;
        try {
-               boolOpResult= BOP_performBooleanOperation( boolType,
-                                                                                                  mesh_info->output_descriptor,
-                                                                                                  (BSP_CSGMesh**) &(mesh_info->output_mesh),
-                                                                                                  mesh_info->obB_descriptor,
-                                                                                                  obBFaces,
-                                                                                                  obBVertices,
-                                                                                                  mesh_info->obA_descriptor,
-                                                                                                  obAFaces,
-                                                                                                  obAVertices,
-                                                                                                  interp_func );
+       BOP_performBooleanOperation( boolType,
+                                    mesh_info->output_descriptor,
+                                    (BSP_CSGMesh**) &(mesh_info->output_mesh),
+                                        mesh_info->obB_descriptor,
+                                        obBFaces,
+                                        obBVertices,
+                                        mesh_info->obA_descriptor,
+                                    obAFaces,
+                                    obAVertices,
+                                    interp_func );
        }
        catch(...) {
                return 0;
        }
 
-       switch (boolOpResult) {
-       case BOP_OK: return 1;
-       case BOP_NO_SOLID: return -2;
-       case BOP_ERROR: return 0;
-       default: return 1;
-       }
+       return success;
 }
 
        int
index 5d30b58a98230ac8a14332934360deeb08912632..3ef20b9be3af4aa302a94a4ce6d510c2135d82cb 100644 (file)
@@ -10,8 +10,6 @@ elbeem_env.Append(CPPDEFINES= [('ELBEEM_BLENDER',1)] );
 if use_fluidsim=='false':
        # print "El'Beem Fluid Simulation Disabled..." # debug
        elbeem_env.Append (CPPPATH = user_options_dict['PNG_INCLUDE'])
-       elbeem_env.Append (CPPPATH = user_options_dict['SDL_INCLUDE'])
-       elbeem_env.Append(CPPDEFINES= 'ELBEEM_DUMMIES');
        # dummy interface build
        Sources = [ 
                "intern/utilities.cpp",
index 3111c9359dd6264b509e94420cf9f86d0413d023..4d672dee528bcecf9d2b9a944aeb0bf030bd5b8f 100644 (file)
@@ -9,30 +9,11 @@
  *
  *****************************************************************************/
  
-#ifdef ELBEEM_DUMMIES
-
 #include <stdlib.h>
-#include "ntl_vector3dim.h"
 
 extern "C" 
 int performElbeemSimulation(char *cfgfilename) {
-       return 1; // dummy
+       return 1;
 };
 
-// dummies from intern/elbeem/intern/solver_interface.cpp
-// for utilities.cpp
-
-void initGridSizes(int &sizex, int &sizey, int &sizez,
-               ntlVec3Gfx &geoStart, ntlVec3Gfx &geoEnd, 
-               int mMaxRefine, bool parallel) 
-{
-       // dummy
-}
-
-void calculateMemreqEstimate( int resx,int resy,int resz, int refine,
-               double *reqret, string *reqstr) {
-       *reqret =  0.0; // dummy
-}
-
-#endif // ELBEEM_DUMMIES
 
index ec6e094efef4b6f8ac7adfb8f5853155bd1d0a24..78b3282b7662f8d4458531fd81c5a9157872abbd 100644 (file)
@@ -70,7 +70,7 @@ PostBuild_Cmds=ECHO copy to lib ...   xcopy /Y .\release\blender_elbeem.lib ..\..\
 # PROP Target_Dir ""
 LINK32=link.exe -lib
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../../../lib/windows/sdl/include" /I "../../../../../lib/windows/zlib/include" /I "../../../../../lib/windows/png/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "NOGUI" /D "ELBEEM_BLENDER" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../../../lib/windows/sdl/include" /I "../../../../../lib/windows/zlib/include" /I "../../../../../lib/windows/png/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "NOGUI" /D "ELBEEM_BLENDER" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x407 /d "_DEBUG"
 # ADD RSC /l 0x407 /d "_DEBUG"
 BSC32=bscmake.exe
index f2c4451233848a38188d54d08d5cc5af238620ac..afd4c345ccd4680787c443526642d34352988845 100644 (file)
@@ -273,9 +273,6 @@ ECHO Done
                        <File
                                RelativePath="..\..\intern\ntl_scene.cpp">
                        </File>
-                       <File
-                               RelativePath="..\..\intern\ntl_world.cpp">
-                       </File>
                        <File
                                RelativePath="..\..\intern\parametrizer.cpp">
                        </File>
@@ -285,18 +282,6 @@ ECHO Done
                        <File
                                RelativePath="..\..\intern\simulation_object.cpp">
                        </File>
-                       <File
-                               RelativePath="..\..\intern\solver_init.cpp">
-                       </File>
-                       <File
-                               RelativePath="..\..\intern\solver_interface.cpp">
-                       </File>
-                       <File
-                               RelativePath="..\..\intern\solver_main.cpp">
-                       </File>
-                       <File
-                               RelativePath="..\..\intern\solver_util.cpp">
-                       </File>
                        <File
                                RelativePath="..\..\intern\utilities.cpp">
                        </File>
@@ -311,9 +296,6 @@ ECHO Done
                        <File
                                RelativePath="..\..\intern\cfgparser.h">
                        </File>
-                       <File
-                               RelativePath="..\..\intern\elbeem.h">
-                       </File>
                        <File
                                RelativePath="..\..\intern\globals.h">
                        </File>
@@ -368,9 +350,6 @@ ECHO Done
                        <File
                                RelativePath="..\..\intern\ntl_vector3dim.h">
                        </File>
-                       <File
-                               RelativePath="..\..\intern\ntl_world.h">
-                       </File>
                        <File
                                RelativePath="..\..\intern\parametrizer.h">
                        </File>
@@ -380,18 +359,6 @@ ECHO Done
                        <File
                                RelativePath="..\..\intern\simulation_object.h">
                        </File>
-                       <File
-                               RelativePath="..\..\intern\solver_class.h">
-                       </File>
-                       <File
-                               RelativePath="..\..\intern\solver_dimenions.h">
-                       </File>
-                       <File
-                               RelativePath="..\..\intern\solver_interface.h">
-                       </File>
-                       <File
-                               RelativePath="..\..\intern\solver_relax.h">
-                       </File>
                        <File
                                RelativePath="..\..\intern\utilities.h">
                        </File>
index ee76349ededded616172d377408535fed415fcf0..d1caadab219edcf7f5d180fbe1c71d9f930f8b0d 100644 (file)
@@ -655,7 +655,6 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                        case kEventWindowActivated:
                                m_windowManager->setActiveWindow(window);
                                window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
-                               window->updateDrawingContext();
                                pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
                                break;
                        case kEventWindowDeactivated:
@@ -664,7 +663,6 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                                break;
                        case kEventWindowUpdate:
                                //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n");
-                               window->updateDrawingContext();
                                pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
                                break;
                        case kEventWindowBoundsChanged:
index 128f1b137bcfb12550dc2e2ba5182165948c9981..345cf0dc7170f8f77b9a98b57a6a375277f24c0b 100644 (file)
@@ -89,10 +89,6 @@ typedef void* NLContext;
 #define NL_SYMMETRIC        0x106
 #define NL_ERROR            0x108
 
-/* Enable / Disable */
-
-#define NL_NORMALIZE_ROWS  0x400
-
 /* Row parameters */
 
 #define NL_RIGHT_HAND_SIDE 0x500
@@ -142,7 +138,9 @@ void nlRightHandSideAdd(NLuint index, NLfloat value);
 
 /* Solve */
 
-NLboolean nlSolve(void);
+void nlPrintMatrix(void);
+NLboolean nlSolve();
+NLboolean nlSolveAdvanced(NLint *permutation, NLboolean solveAgain);
 
 #ifdef __cplusplus
 }
index 7773582e0272932262883ea2424bc18b7c5d29c3..c5518731c6bccf3e106cebbde1ad36d9715ad2f8 100644 (file)
  *
  *  Contact: Bruno Levy
  *
- *     levy@loria.fr
+ *      levy@loria.fr
  *
- *     ISA Project
- *     LORIA, INRIA Lorraine, 
- *     Campus Scientifique, BP 239
- *     54506 VANDOEUVRE LES NANCY CEDEX 
- *     FRANCE
+ *      ISA Project
+ *      LORIA, INRIA Lorraine, 
+ *      Campus Scientifique, BP 239
+ *      54506 VANDOEUVRE LES NANCY CEDEX 
+ *      FRANCE
  *
  *  Note that the GNU General Public License does not permit incorporating
  *  the Software into proprietary programs. 
 
 
 static void __nl_assertion_failed(char* cond, char* file, int line) {
-    fprintf(
-        stderr, 
-        "OpenNL assertion failed: %s, file:%s, line:%d\n",
-        cond,file,line
-    );
-    abort();
+       fprintf(
+               stderr, 
+               "OpenNL assertion failed: %s, file:%s, line:%d\n",
+               cond,file,line
+       );
+       abort();
 }
 
 static void __nl_range_assertion_failed(
-    float x, float min_val, float max_val, char* file, int line
+       float x, float min_val, float max_val, char* file, int line
 ) {
-    fprintf(
-        stderr, 
-        "OpenNL range assertion failed: %f in [ %f ... %f ], file:%s, line:%d\n",
-        x, min_val, max_val, file,line
-    );
-    abort();
+       fprintf(
+               stderr, 
+               "OpenNL range assertion failed: %f in [ %f ... %f ], file:%s, line:%d\n",
+               x, min_val, max_val, file,line
+       );
+       abort();
 }
 
 static void __nl_should_not_have_reached(char* file, int line) {
-    fprintf(
-        stderr, 
-        "OpenNL should not have reached this point: file:%s, line:%d\n",
-        file,line
-    );
-    abort();
+       fprintf(
+               stderr, 
+               "OpenNL should not have reached this point: file:%s, line:%d\n",
+               file,line
+       );
+       abort();
 }
 
 
-#define __nl_assert(x) {                                        \
-    if(!(x)) {                                                  \
-        __nl_assertion_failed(#x,__FILE__, __LINE__);          \
-    }                                                           \
+#define __nl_assert(x) {                                                                               \
+       if(!(x)) {                                                                                                \
+               __nl_assertion_failed(#x,__FILE__, __LINE__);             \
+       }                                                                                                                  \
 } 
 
-#define __nl_range_assert(x,min_val,max_val) {                  \
-    if(((x) < (min_val)) || ((x) > (max_val))) {                \
-        __nl_range_assertion_failed(x, min_val, max_val,        \
-            __FILE__, __LINE__                                  \
-        );                                                     \
-    }                                                           \
+#define __nl_range_assert(x,min_val,max_val) {                           \
+       if(((x) < (min_val)) || ((x) > (max_val))) {                            \
+               __nl_range_assertion_failed(x, min_val, max_val,                \
+                       __FILE__, __LINE__                                                                \
+               );                                                                                                       \
+       }                                                                                                                  \
 }
 
-#define __nl_assert_not_reached {                               \
-    __nl_should_not_have_reached(__FILE__, __LINE__);          \
+#define __nl_assert_not_reached {                                                         \
+       __nl_should_not_have_reached(__FILE__, __LINE__);                 \
 }
 
 #ifdef NL_DEBUG
@@ -135,301 +135,301 @@ static void __nl_should_not_have_reached(char* file, int line) {
 /************************************************************************************/
 /* memory management */
 
-#define __NL_NEW(T)                (T*)(calloc(1, sizeof(T))) 
-#define __NL_NEW_ARRAY(T,NB)       (T*)(calloc((NB),sizeof(T))) 
+#define __NL_NEW(T)                            (T*)(calloc(1, sizeof(T))) 
+#define __NL_NEW_ARRAY(T,NB)      (T*)(calloc((NB),sizeof(T))) 
 #define __NL_RENEW_ARRAY(T,x,NB)   (T*)(realloc(x,(NB)*sizeof(T))) 
-#define __NL_DELETE(x)             free(x); x = NULL 
-#define __NL_DELETE_ARRAY(x)       free(x); x = NULL
+#define __NL_DELETE(x)                  free(x); x = NULL 
+#define __NL_DELETE_ARRAY(x)      free(x); x = NULL
 
-#define __NL_CLEAR(T, x)           memset(x, 0, sizeof(T)) 
+#define __NL_CLEAR(T, x)                  memset(x, 0, sizeof(T)) 
 #define __NL_CLEAR_ARRAY(T,x,NB)   memset(x, 0, (NB)*sizeof(T)) 
 
 /************************************************************************************/
 /* Dynamic arrays for sparse row/columns */
 
 typedef struct {
-    NLuint   index;
-    NLfloat value;
+       NLuint   index;
+       NLfloat value;
 } __NLCoeff;
 
 typedef struct {
-    NLuint size;
-    NLuint capacity;
-    __NLCoeff* coeff;
+       NLuint size;
+       NLuint capacity;
+       __NLCoeff* coeff;
 } __NLRowColumn;
 
 static void __nlRowColumnConstruct(__NLRowColumn* c) {
-    c->size     = 0;
-    c->capacity = 0;
-    c->coeff    = NULL;
+       c->size  = 0;
+       c->capacity = 0;
+       c->coeff        = NULL;
 }
 
 static void __nlRowColumnDestroy(__NLRowColumn* c) {
-    __NL_DELETE_ARRAY(c->coeff);
+       __NL_DELETE_ARRAY(c->coeff);
 #ifdef NL_PARANOID
-    __NL_CLEAR(__NLRowColumn, c); 
+       __NL_CLEAR(__NLRowColumn, c); 
 #endif
 }
 
 static void __nlRowColumnGrow(__NLRowColumn* c) {
-    if(c->capacity != 0) {
-        c->capacity = 2 * c->capacity;
-        c->coeff = __NL_RENEW_ARRAY(__NLCoeff, c->coeff, c->capacity);
-    } else {
-        c->capacity = 4;
-        c->coeff = __NL_NEW_ARRAY(__NLCoeff, c->capacity);
-    }
+       if(c->capacity != 0) {
+               c->capacity = 2 * c->capacity;
+               c->coeff = __NL_RENEW_ARRAY(__NLCoeff, c->coeff, c->capacity);
+       } else {
+               c->capacity = 4;
+               c->coeff = __NL_NEW_ARRAY(__NLCoeff, c->capacity);
+       }
 }
 
 static void __nlRowColumnAdd(__NLRowColumn* c, NLint index, NLfloat value) {
-    NLuint i;
-    for(i=0; i<c->size; i++) {
-        if(c->coeff[i].index == (NLuint)index) {
-            c->coeff[i].value += value;
-            return;
-        }
-    }
-    if(c->size == c->capacity) {
-        __nlRowColumnGrow(c);
-    }
-    c->coeff[c->size].index = index;
-    c->coeff[c->size].value = value;
-    c->size++;
+       NLuint i;
+       for(i=0; i<c->size; i++) {
+               if(c->coeff[i].index == (NLuint)index) {
+                       c->coeff[i].value += value;
+                       return;
+               }
+       }
+       if(c->size == c->capacity) {
+               __nlRowColumnGrow(c);
+       }
+       c->coeff[c->size].index = index;
+       c->coeff[c->size].value = value;
+       c->size++;
 }
 
 /* Does not check whether the index already exists */
 static void __nlRowColumnAppend(__NLRowColumn* c, NLint index, NLfloat value) {
-    if(c->size == c->capacity) {
-        __nlRowColumnGrow(c);
-    }
-    c->coeff[c->size].index = index;
-    c->coeff[c->size].value = value;
-    c->size++;
+       if(c->size == c->capacity) {
+               __nlRowColumnGrow(c);
+       }
+       c->coeff[c->size].index = index;
+       c->coeff[c->size].value = value;
+       c->size++;
 }
 
 static void __nlRowColumnZero(__NLRowColumn* c) {
-    c->size = 0;
+       c->size = 0;
 }
 
 static void __nlRowColumnClear(__NLRowColumn* c) {
-    c->size     = 0;
-    c->capacity = 0;
-    __NL_DELETE_ARRAY(c->coeff);
+       c->size  = 0;
+       c->capacity = 0;
+       __NL_DELETE_ARRAY(c->coeff);
 }
 
 /************************************************************************************/
 /* SparseMatrix data structure */
 
-#define __NL_ROWS      1
+#define __NL_ROWS        1
 #define __NL_COLUMNS   2
 #define __NL_SYMMETRIC 4
 
 typedef struct {
-    NLuint m;
-    NLuint n;
-    NLuint diag_size;
-    NLenum storage;
-    __NLRowColumn* row;
-    __NLRowColumn* column;
-    NLfloat*      diag;
+       NLuint m;
+       NLuint n;
+       NLuint diag_size;
+       NLenum storage;
+       __NLRowColumn* row;
+       __NLRowColumn* column;
+       NLfloat*          diag;
 } __NLSparseMatrix;
 
 
 static void __nlSparseMatrixConstruct(
-    __NLSparseMatrix* M, NLuint m, NLuint n, NLenum storage
+       __NLSparseMatrix* M, NLuint m, NLuint n, NLenum storage
 ) {
-    NLuint i;
-    M->m = m;
-    M->n = n;
-    M->storage = storage;
-    if(storage & __NL_ROWS) {
-        M->row = __NL_NEW_ARRAY(__NLRowColumn, m);
-        for(i=0; i<n; i++) {
-            __nlRowColumnConstruct(&(M->row[i]));
-        }
-    } else {
-        M->row = NULL;
-    }
-
-    if(storage & __NL_COLUMNS) {
-        M->column = __NL_NEW_ARRAY(__NLRowColumn, n);
-        for(i=0; i<n; i++) {
-            __nlRowColumnConstruct(&(M->column[i]));
-        }
-    } else {
-        M->column = NULL;
-    }
-
-    M->diag_size = MIN(m,n);
-    M->diag = __NL_NEW_ARRAY(NLfloat, M->diag_size);
+       NLuint i;
+       M->m = m;
+       M->n = n;
+       M->storage = storage;
+       if(storage & __NL_ROWS) {
+               M->row = __NL_NEW_ARRAY(__NLRowColumn, m);
+               for(i=0; i<n; i++) {
+                       __nlRowColumnConstruct(&(M->row[i]));
+               }
+       } else {
+               M->row = NULL;
+       }
+
+       if(storage & __NL_COLUMNS) {
+               M->column = __NL_NEW_ARRAY(__NLRowColumn, n);
+               for(i=0; i<n; i++) {
+                       __nlRowColumnConstruct(&(M->column[i]));
+               }
+       } else {
+               M->column = NULL;
+       }
+
+       M->diag_size = MIN(m,n);
+       M->diag = __NL_NEW_ARRAY(NLfloat, M->diag_size);
 }
 
 static void __nlSparseMatrixDestroy(__NLSparseMatrix* M) {
-    NLuint i;
-    __NL_DELETE_ARRAY(M->diag);
-    if(M->storage & __NL_ROWS) {
-        for(i=0; i<M->m; i++) {
-            __nlRowColumnDestroy(&(M->row[i]));
-        }
-        __NL_DELETE_ARRAY(M->row);
-    }
-    if(M->storage & __NL_COLUMNS) {
-        for(i=0; i<M->n; i++) {
-            __nlRowColumnDestroy(&(M->column[i]));
-        }
-        __NL_DELETE_ARRAY(M->column);
-    }
+       NLuint i;
+       __NL_DELETE_ARRAY(M->diag);
+       if(M->storage & __NL_ROWS) {
+               for(i=0; i<M->m; i++) {
+                       __nlRowColumnDestroy(&(M->row[i]));
+               }
+               __NL_DELETE_ARRAY(M->row);
+       }
+       if(M->storage & __NL_COLUMNS) {
+               for(i=0; i<M->n; i++) {
+                       __nlRowColumnDestroy(&(M->column[i]));
+               }
+               __NL_DELETE_ARRAY(M->column);
+       }
 #ifdef NL_PARANOID
-    __NL_CLEAR(__NLSparseMatrix,M);
+       __NL_CLEAR(__NLSparseMatrix,M);
 #endif
 }
 
 static void __nlSparseMatrixAdd(
-    __NLSparseMatrix* M, NLuint i, NLuint j, NLfloat value
+       __NLSparseMatrix* M, NLuint i, NLuint j, NLfloat value
 ) {
-    __nl_parano_range_assert(i, 0, M->m - 1);
-    __nl_parano_range_assert(j, 0, M->n - 1);
-    if((M->storage & __NL_SYMMETRIC) && (j > i)) {
-        return;
-    }
-    if(i == j) {
-        M->diag[i] += value;
-    }
-    if(M->storage & __NL_ROWS) {
-        __nlRowColumnAdd(&(M->row[i]), j, value);
-    }
-    if(M->storage & __NL_COLUMNS) {
-        __nlRowColumnAdd(&(M->column[j]), i, value);
-    }
+       __nl_parano_range_assert(i, 0, M->m - 1);
+       __nl_parano_range_assert(j, 0, M->n - 1);
+       if((M->storage & __NL_SYMMETRIC) && (j > i)) {
+               return;
+       }
+       if(i == j) {
+               M->diag[i] += value;
+       }
+       if(M->storage & __NL_ROWS) {
+               __nlRowColumnAdd(&(M->row[i]), j, value);
+       }
+       if(M->storage & __NL_COLUMNS) {
+               __nlRowColumnAdd(&(M->column[j]), i, value);
+       }
 }
 
 static void __nlSparseMatrixClear( __NLSparseMatrix* M) {
-    NLuint i;
-    if(M->storage & __NL_ROWS) {
-        for(i=0; i<M->m; i++) {
-            __nlRowColumnClear(&(M->row[i]));
-        }
-    }
-    if(M->storage & __NL_COLUMNS) {
-        for(i=0; i<M->n; i++) {
-            __nlRowColumnClear(&(M->column[i]));
-        }
-    }
-    __NL_CLEAR_ARRAY(NLfloat, M->diag, M->diag_size);    
+       NLuint i;
+       if(M->storage & __NL_ROWS) {
+               for(i=0; i<M->m; i++) {
+                       __nlRowColumnClear(&(M->row[i]));
+               }
+       }
+       if(M->storage & __NL_COLUMNS) {
+               for(i=0; i<M->n; i++) {
+                       __nlRowColumnClear(&(M->column[i]));
+               }
+       }
+       __NL_CLEAR_ARRAY(NLfloat, M->diag, M->diag_size);       
 }
 
 /* Returns the number of non-zero coefficients */
 static NLuint __nlSparseMatrixNNZ( __NLSparseMatrix* M) {
-    NLuint nnz = 0;
-    NLuint i;
-    if(M->storage & __NL_ROWS) {
-        for(i = 0; i<M->m; i++) {
-            nnz += M->row[i].size;
-        }
-    } else if (M->storage & __NL_COLUMNS) {
-        for(i = 0; i<M->n; i++) {
-            nnz += M->column[i].size;
-        }
-    } else {
-        __nl_assert_not_reached;
-    }
-    return nnz;
+       NLuint nnz = 0;
+       NLuint i;
+       if(M->storage & __NL_ROWS) {
+               for(i = 0; i<M->m; i++) {
+                       nnz += M->row[i].size;
+               }
+       } else if (M->storage & __NL_COLUMNS) {
+               for(i = 0; i<M->n; i++) {
+                       nnz += M->column[i].size;
+               }
+       } else {
+               __nl_assert_not_reached;
+       }
+       return nnz;
 }
 
 /************************************************************************************/
 /* SparseMatrix x Vector routines, internal helper routines */
 
 static void __nlSparseMatrix_mult_rows_symmetric(
-    __NLSparseMatrix* A, NLfloat* x, NLfloat* y
+       __NLSparseMatrix* A, NLfloat* x, NLfloat* y
 ) {
-    NLuint m = A->m;
-    NLuint i,ij;
-    __NLRowColumn* Ri = NULL;
-    __NLCoeff* c = NULL;
-    for(i=0; i<m; i++) {
-        y[i] = 0;
-        Ri = &(A->row[i]);
-        for(ij=0; ij<Ri->size; ij++) {
-            c = &(Ri->coeff[ij]);
-            y[i] += c->value * x[c->index];
-            if(i != c->index) {
-                y[c->index] += c->value * x[i];
-            }
-        }
-    }
+       NLuint m = A->m;
+       NLuint i,ij;
+       __NLRowColumn* Ri = NULL;
+       __NLCoeff* c = NULL;
+       for(i=0; i<m; i++) {
+               y[i] = 0;
+               Ri = &(A->row[i]);
+               for(ij=0; ij<Ri->size; ij++) {
+                       c = &(Ri->coeff[ij]);
+                       y[i] += c->value * x[c->index];
+                       if(i != c->index) {
+                               y[c->index] += c->value * x[i];
+                       }
+               }
+       }
 }
 
 static void __nlSparseMatrix_mult_rows(
-    __NLSparseMatrix* A, NLfloat* x, NLfloat* y
+       __NLSparseMatrix* A, NLfloat* x, NLfloat* y
 ) {
-    NLuint m = A->m;
-    NLuint i,ij;
-    __NLRowColumn* Ri = NULL;
-    __NLCoeff* c = NULL;
-    for(i=0; i<m; i++) {
-        y[i] = 0;
-        Ri = &(A->row[i]);
-        for(ij=0; ij<Ri->size; ij++) {
-            c = &(Ri->coeff[ij]);
-            y[i] += c->value * x[c->index];
-        }
-    }
+       NLuint m = A->m;
+       NLuint i,ij;
+       __NLRowColumn* Ri = NULL;
+       __NLCoeff* c = NULL;
+       for(i=0; i<m; i++) {
+               y[i] = 0;
+               Ri = &(A->row[i]);
+               for(ij=0; ij<Ri->size; ij++) {
+                       c = &(Ri->coeff[ij]);
+                       y[i] += c->value * x[c->index];
+               }
+       }
 }
 
 static void __nlSparseMatrix_mult_cols_symmetric(
-    __NLSparseMatrix* A, NLfloat* x, NLfloat* y
+       __NLSparseMatrix* A, NLfloat* x, NLfloat* y
 ) {
-    NLuint n = A->n;
-    NLuint j,ii;
-    __NLRowColumn* Cj = NULL;
-    __NLCoeff* c = NULL;
-    for(j=0; j<n; j++) {
-        y[j] = 0;
-        Cj = &(A->column[j]);
-        for(ii=0; ii<Cj->size; ii++) {
-            c = &(Cj->coeff[ii]);
-            y[c->index] += c->value * x[j];
-            if(j != c->index) {
-                y[j] += c->value * x[c->index];
-            }
-        }
-    }
+       NLuint n = A->n;
+       NLuint j,ii;
+       __NLRowColumn* Cj = NULL;
+       __NLCoeff* c = NULL;
+       for(j=0; j<n; j++) {
+               y[j] = 0;
+               Cj = &(A->column[j]);
+               for(ii=0; ii<Cj->size; ii++) {
+                       c = &(Cj->coeff[ii]);
+                       y[c->index] += c->value * x[j];
+                       if(j != c->index) {
+                               y[j] += c->value * x[c->index];
+                       }
+               }
+       }
 }
 
 static void __nlSparseMatrix_mult_cols(
-    __NLSparseMatrix* A, NLfloat* x, NLfloat* y
+       __NLSparseMatrix* A, NLfloat* x, NLfloat* y
 ) {
-    NLuint n = A->n;
-    NLuint j,ii; 
-    __NLRowColumn* Cj = NULL;
-    __NLCoeff* c = NULL;
-    __NL_CLEAR_ARRAY(NLfloat, y, A->m);
-    for(j=0; j<n; j++) {
-        Cj = &(A->column[j]);
-        for(ii=0; ii<Cj->size; ii++) {
-            c = &(Cj->coeff[ii]);
-            y[c->index] += c->value * x[j];
-        }
-    }
+       NLuint n = A->n;
+       NLuint j,ii; 
+       __NLRowColumn* Cj = NULL;
+       __NLCoeff* c = NULL;
+       __NL_CLEAR_ARRAY(NLfloat, y, A->m);
+       for(j=0; j<n; j++) {
+               Cj = &(A->column[j]);
+               for(ii=0; ii<Cj->size; ii++) {
+                       c = &(Cj->coeff[ii]);
+                       y[c->index] += c->value * x[j];
+               }
+       }
 }
 
 /************************************************************************************/
 /* SparseMatrix x Vector routines, main driver routine */
 
 static void __nlSparseMatrixMult(__NLSparseMatrix* A, NLfloat* x, NLfloat* y) {
-    if(A->storage & __NL_ROWS) {
-        if(A->storage & __NL_SYMMETRIC) {
-            __nlSparseMatrix_mult_rows_symmetric(A, x, y);
-        } else {
-            __nlSparseMatrix_mult_rows(A, x, y);
-        }
-    } else {
-        if(A->storage & __NL_SYMMETRIC) {
-            __nlSparseMatrix_mult_cols_symmetric(A, x, y);
-        } else {
-            __nlSparseMatrix_mult_cols(A, x, y);
-        }
-    }
+       if(A->storage & __NL_ROWS) {
+               if(A->storage & __NL_SYMMETRIC) {
+                       __nlSparseMatrix_mult_rows_symmetric(A, x, y);
+               } else {
+                       __nlSparseMatrix_mult_rows(A, x, y);
+               }
+       } else {
+               if(A->storage & __NL_SYMMETRIC) {
+                       __nlSparseMatrix_mult_cols_symmetric(A, x, y);
+               } else {
+                       __nlSparseMatrix_mult_cols(A, x, y);
+               }
+       }
 }
 
 /************************************************************************************/
@@ -438,513 +438,467 @@ static void __nlSparseMatrixMult(__NLSparseMatrix* A, NLfloat* x, NLfloat* y) {
 typedef void(*__NLMatrixFunc)(float* x, float* y);
 
 typedef struct {
-    NLfloat  value;
-    NLboolean locked;
-    NLuint    index;
+       NLfloat  value;
+       NLboolean locked;
+       NLuint  index;
 } __NLVariable;
 
-#define __NL_STATE_INITIAL            0
-#define __NL_STATE_SYSTEM             1
-#define __NL_STATE_MATRIX             2
-#define __NL_STATE_ROW                3
-#define __NL_STATE_MATRIX_CONSTRUCTED 4
-#define __NL_STATE_SYSTEM_CONSTRUCTED 5
-#define __NL_STATE_SOLVED             6
+#define __NL_STATE_INITIAL                             0
+#define __NL_STATE_SYSTEM                              1
+#define __NL_STATE_MATRIX                              2
+#define __NL_STATE_ROW                                 3
+#define __NL_STATE_MATRIX_CONSTRUCTED  4
+#define __NL_STATE_SYSTEM_CONSTRUCTED  5
+#define __NL_STATE_SYSTEM_SOLVED               7
 
 typedef struct {
-    NLenum           state;
-    __NLVariable*    variable;
-    NLuint           n;
-    __NLSparseMatrix M;
-    __NLRowColumn    af;
-    __NLRowColumn    al;
-    __NLRowColumn    xl;
-    NLfloat*        x;
-    NLfloat*        b;
-    NLfloat         right_hand_side;
-    NLfloat         row_scaling;
-    NLuint           nb_variables;
-    NLuint           current_row;
-    NLboolean        least_squares;
-    NLboolean        symmetric;
-    NLboolean        normalize_rows;
-    NLboolean        alloc_M;
-    NLboolean        alloc_af;
-    NLboolean        alloc_al;
-    NLboolean        alloc_xl;
-    NLboolean        alloc_variable;
-    NLboolean        alloc_x;
-    NLboolean        alloc_b;
-    NLfloat         error;
-    __NLMatrixFunc   matrix_vector_prod;
+       NLenum             state;
+       __NLVariable*   variable;
+       NLuint             n;
+       __NLSparseMatrix M;
+       __NLRowColumn   af;
+       __NLRowColumn   al;
+       NLfloat*                x;
+       NLfloat*                b;
+       NLfloat          right_hand_side;
+       NLuint             nb_variables;
+       NLuint             current_row;
+       NLboolean               least_squares;
+       NLboolean               symmetric;
+       NLboolean               solve_again;
+       NLboolean               alloc_M;
+       NLboolean               alloc_af;
+       NLboolean               alloc_al;
+       NLboolean               alloc_variable;
+       NLboolean               alloc_x;
+       NLboolean               alloc_b;
+       NLfloat          error;
+       __NLMatrixFunc   matrix_vector_prod;
+
+       struct __NLSuperLUContext {
+               NLboolean alloc_slu;
+               SuperMatrix L, U;
+               NLint *perm_c, *perm_r;
+               SuperLUStat_t stat;
+       } slu;
 } __NLContext;
 
 static __NLContext* __nlCurrentContext = NULL;
 
 static void __nlMatrixVectorProd_default(NLfloat* x, NLfloat* y) {
-    __nlSparseMatrixMult(&(__nlCurrentContext->M), x, y);
+       __nlSparseMatrixMult(&(__nlCurrentContext->M), x, y);
 }
 
 
 NLContext nlNewContext(void) {
-    __NLContext* result      = __NL_NEW(__NLContext);
-    result->state            = __NL_STATE_INITIAL;
-    result->row_scaling      = 1.0;
-    result->right_hand_side  = 0.0;
-    result->matrix_vector_prod = __nlMatrixVectorProd_default;
-    nlMakeCurrent(result);
-    return result;
+       __NLContext* result       = __NL_NEW(__NLContext);
+       result->state                   = __NL_STATE_INITIAL;
+       result->right_hand_side  = 0.0;
+       result->matrix_vector_prod = __nlMatrixVectorProd_default;
+       nlMakeCurrent(result);
+       return result;
 }
 
+static void __nlFree_SUPERLU(__NLContext *context);
+
 void nlDeleteContext(NLContext context_in) {
-    __NLContext* context = (__NLContext*)(context_in);
-    if(__nlCurrentContext == context) {
-        __nlCurrentContext = NULL;
-    }
-    if(context->alloc_M) {
-        __nlSparseMatrixDestroy(&context->M);
-    }
-    if(context->alloc_af) {
-        __nlRowColumnDestroy(&context->af);
-    }
-    if(context->alloc_al) {
-        __nlRowColumnDestroy(&context->al);
-    }
-    if(context->alloc_xl) {
-        __nlRowColumnDestroy(&context->xl);
-    }
-    if(context->alloc_variable) {
-        __NL_DELETE_ARRAY(context->variable);
-    }
-    if(context->alloc_x) {
-        __NL_DELETE_ARRAY(context->x);
-    }
-    if(context->alloc_b) {
-        __NL_DELETE_ARRAY(context->b);
-    }
+       __NLContext* context = (__NLContext*)(context_in);
+       if(__nlCurrentContext == context) {
+               __nlCurrentContext = NULL;
+       }
+       if(context->alloc_M) {
+               __nlSparseMatrixDestroy(&context->M);
+       }
+       if(context->alloc_af) {
+               __nlRowColumnDestroy(&context->af);
+       }
+       if(context->alloc_al) {
+               __nlRowColumnDestroy(&context->al);
+       }
+       if(context->alloc_variable) {
+               __NL_DELETE_ARRAY(context->variable);
+       }
+       if(context->alloc_x) {
+               __NL_DELETE_ARRAY(context->x);
+       }
+       if(context->alloc_b) {
+               __NL_DELETE_ARRAY(context->b);
+       }
+       if (context->slu.alloc_slu) {
+               __nlFree_SUPERLU(context);
+       }
 
 #ifdef NL_PARANOID
-    __NL_CLEAR(__NLContext, context);
+       __NL_CLEAR(__NLContext, context);
 #endif
-    __NL_DELETE(context);
+       __NL_DELETE(context);
 }
 
 void nlMakeCurrent(NLContext context) {
-    __nlCurrentContext = (__NLContext*)(context);
+       __nlCurrentContext = (__NLContext*)(context);
 }
 
 NLContext nlGetCurrent(void) {
-    return __nlCurrentContext;
+       return __nlCurrentContext;
 }
 
 static void __nlCheckState(NLenum state) {
-    __nl_assert(__nlCurrentContext->state == state);
+       __nl_assert(__nlCurrentContext->state == state);
 }
 
 static void __nlTransition(NLenum from_state, NLenum to_state) {
-    __nlCheckState(from_state);
-    __nlCurrentContext->state = to_state;
+       __nlCheckState(from_state);
+       __nlCurrentContext->state = to_state;
 }
 
 /************************************************************************************/
 /* Get/Set parameters */
 
 void nlSolverParameterf(NLenum pname, NLfloat param) {
-    __nlCheckState(__NL_STATE_INITIAL);
-    switch(pname) {
-    case NL_NB_VARIABLES: {
-        __nl_assert(param > 0);
-        __nlCurrentContext->nb_variables = (NLuint)param;
-    } break;
-    case NL_LEAST_SQUARES: {
-        __nlCurrentContext->least_squares = (NLboolean)param;
-    } break;
-    case NL_SYMMETRIC: {
-        __nlCurrentContext->symmetric = (NLboolean)param;        
-    }
-    default: {
-        __nl_assert_not_reached;
-    } break;
-    }
+       __nlCheckState(__NL_STATE_INITIAL);
+       switch(pname) {
+       case NL_NB_VARIABLES: {
+               __nl_assert(param > 0);
+               __nlCurrentContext->nb_variables = (NLuint)param;
+       } break;
+       case NL_LEAST_SQUARES: {
+               __nlCurrentContext->least_squares = (NLboolean)param;
+       } break;
+       case NL_SYMMETRIC: {
+               __nlCurrentContext->symmetric = (NLboolean)param;               
+       }
+       default: {
+               __nl_assert_not_reached;
+       } break;
+       }
 }
 
 void nlSolverParameteri(NLenum pname, NLint param) {
-    __nlCheckState(__NL_STATE_INITIAL);
-    switch(pname) {
-    case NL_NB_VARIABLES: {
-        __nl_assert(param > 0);
-        __nlCurrentContext->nb_variables = (NLuint)param;
-    } break;
-    case NL_LEAST_SQUARES: {
-        __nlCurrentContext->least_squares = (NLboolean)param;
-    } break;
-    case NL_SYMMETRIC: {
-        __nlCurrentContext->symmetric = (NLboolean)param;        
-    }
-    default: {
-        __nl_assert_not_reached;
-    } break;
-    }
+       __nlCheckState(__NL_STATE_INITIAL);
+       switch(pname) {
+       case NL_NB_VARIABLES: {
+               __nl_assert(param > 0);
+               __nlCurrentContext->nb_variables = (NLuint)param;
+       } break;
+       case NL_LEAST_SQUARES: {
+               __nlCurrentContext->least_squares = (NLboolean)param;
+       } break;
+       case NL_SYMMETRIC: {
+               __nlCurrentContext->symmetric = (NLboolean)param;               
+       }
+       default: {
+               __nl_assert_not_reached;
+       } break;
+       }
 }
 
 void nlRowParameterf(NLenum pname, NLfloat param) {
-    __nlCheckState(__NL_STATE_MATRIX);
-    switch(pname) {
-    case NL_RIGHT_HAND_SIDE: {
-        __nlCurrentContext->right_hand_side = param;
-    } break;
-    case NL_ROW_SCALING: {
-        __nlCurrentContext->row_scaling = param;
-    } break;
-    }
+       __nlCheckState(__NL_STATE_MATRIX);
+       switch(pname) {
+       case NL_RIGHT_HAND_SIDE: {
+               __nlCurrentContext->right_hand_side = param;
+       } break;
+       }
 }
 
 void nlRowParameteri(NLenum pname, NLint param) {
-    __nlCheckState(__NL_STATE_MATRIX);
-    switch(pname) {
-    case NL_RIGHT_HAND_SIDE: {
-        __nlCurrentContext->right_hand_side = (NLfloat)param;
-    } break;
-    case NL_ROW_SCALING: {
-        __nlCurrentContext->row_scaling = (NLfloat)param;
-    } break;
-    }
+       __nlCheckState(__NL_STATE_MATRIX);
+       switch(pname) {
+       case NL_RIGHT_HAND_SIDE: {
+               __nlCurrentContext->right_hand_side = (NLfloat)param;
+       } break;
+       }
 }
 
 void nlGetBooleanv(NLenum pname, NLboolean* params) {
-    switch(pname) {
-    case NL_LEAST_SQUARES: {
-        *params = __nlCurrentContext->least_squares;
-    } break;
-    case NL_SYMMETRIC: {
-        *params = __nlCurrentContext->symmetric;
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    } break;
-    }
+       switch(pname) {
+       case NL_LEAST_SQUARES: {
+               *params = __nlCurrentContext->least_squares;
+       } break;
+       case NL_SYMMETRIC: {
+               *params = __nlCurrentContext->symmetric;
+       } break;
+       default: {
+               __nl_assert_not_reached;
+       } break;
+       }
 }
 
 void nlGetFloatv(NLenum pname, NLfloat* params) {
-    switch(pname) {
-    case NL_NB_VARIABLES: {
-        *params = (NLfloat)(__nlCurrentContext->nb_variables);
-    } break;
-    case NL_LEAST_SQUARES: {
-        *params = (NLfloat)(__nlCurrentContext->least_squares);
-    } break;
-    case NL_SYMMETRIC: {
-        *params = (NLfloat)(__nlCurrentContext->symmetric);
-    } break;
-    case NL_ERROR: {
-        *params = (NLfloat)(__nlCurrentContext->error);
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    } break;
-    }
+       switch(pname) {
+       case NL_NB_VARIABLES: {
+               *params = (NLfloat)(__nlCurrentContext->nb_variables);
+       } break;
+       case NL_LEAST_SQUARES: {
+               *params = (NLfloat)(__nlCurrentContext->least_squares);
+       } break;
+       case NL_SYMMETRIC: {
+               *params = (NLfloat)(__nlCurrentContext->symmetric);
+       } break;
+       case NL_ERROR: {
+               *params = (NLfloat)(__nlCurrentContext->error);
+       } break;
+       default: {
+               __nl_assert_not_reached;
+       } break;
+       }
 }
 
 void nlGetIntergerv(NLenum pname, NLint* params) {
-    switch(pname) {
-    case NL_NB_VARIABLES: {
-        *params = (NLint)(__nlCurrentContext->nb_variables);
-    } break;
-    case NL_LEAST_SQUARES: {
-        *params = (NLint)(__nlCurrentContext->least_squares);
-    } break;
-    case NL_SYMMETRIC: {
-        *params = (NLint)(__nlCurrentContext->symmetric);
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    } break;
-    }
+       switch(pname) {
+       case NL_NB_VARIABLES: {
+               *params = (NLint)(__nlCurrentContext->nb_variables);
+       } break;
+       case NL_LEAST_SQUARES: {
+               *params = (NLint)(__nlCurrentContext->least_squares);
+       } break;
+       case NL_SYMMETRIC: {
+               *params = (NLint)(__nlCurrentContext->symmetric);
+       } break;
+       default: {
+               __nl_assert_not_reached;
+       } break;
+       }
 }
 
 /************************************************************************************/
 /* Enable / Disable */
 
 void nlEnable(NLenum pname) {
-    switch(pname) {
-    case NL_NORMALIZE_ROWS: {
-        __nl_assert(__nlCurrentContext->state != __NL_STATE_ROW);
-        __nlCurrentContext->normalize_rows = NL_TRUE;
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    }
-    }
+       switch(pname) {
+       default: {
+               __nl_assert_not_reached;
+       }
+       }
 }
 
 void nlDisable(NLenum pname) {
-    switch(pname) {
-    case NL_NORMALIZE_ROWS: {
-        __nl_assert(__nlCurrentContext->state != __NL_STATE_ROW);
-        __nlCurrentContext->normalize_rows = NL_FALSE;
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    }
-    }
+       switch(pname) {
+       default: {
+               __nl_assert_not_reached;
+       }
+       }
 }
 
 NLboolean nlIsEnabled(NLenum pname) {
-    switch(pname) {
-    case NL_NORMALIZE_ROWS: {
-        return __nlCurrentContext->normalize_rows;
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    }
-    }
-    return NL_FALSE;
+       switch(pname) {
+       default: {
+               __nl_assert_not_reached;
+       }
+       }
+       return NL_FALSE;
 }
 
 /************************************************************************************/
 /* Get/Set Lock/Unlock variables */
 
 void nlSetVariable(NLuint index, NLfloat value) {
-    __nlCheckState(__NL_STATE_SYSTEM);
-    __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
-    __nlCurrentContext->variable[index].value = value;    
+       __nlCheckState(__NL_STATE_SYSTEM);
+       __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
+       __nlCurrentContext->variable[index].value = value;      
 }
 
 NLfloat nlGetVariable(NLuint index) {
-    __nl_assert(__nlCurrentContext->state != __NL_STATE_INITIAL);
-    __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
-    return __nlCurrentContext->variable[index].value;
+       __nl_assert(__nlCurrentContext->state != __NL_STATE_INITIAL);
+       __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
+       return __nlCurrentContext->variable[index].value;
 }
 
 void nlLockVariable(NLuint index) {
-    __nlCheckState(__NL_STATE_SYSTEM);
-    __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
-    __nlCurrentContext->variable[index].locked = NL_TRUE;
+       __nlCheckState(__NL_STATE_SYSTEM);
+       __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
+       __nlCurrentContext->variable[index].locked = NL_TRUE;
 }
 
 void nlUnlockVariable(NLuint index) {
-    __nlCheckState(__NL_STATE_SYSTEM);
-    __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
-    __nlCurrentContext->variable[index].locked = NL_FALSE;
+       __nlCheckState(__NL_STATE_SYSTEM);
+       __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
+       __nlCurrentContext->variable[index].locked = NL_FALSE;
 }
 
 NLboolean nlVariableIsLocked(NLuint index) {
-    __nl_assert(__nlCurrentContext->state != __NL_STATE_INITIAL);
-    __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
-    return __nlCurrentContext->variable[index].locked;
+       __nl_assert(__nlCurrentContext->state != __NL_STATE_INITIAL);
+       __nl_parano_range_assert(index, 0, __nlCurrentContext->nb_variables - 1);
+       return __nlCurrentContext->variable[index].locked;
 }
 
 /************************************************************************************/
 /* System construction */
 
 static void __nlVariablesToVector() {
-    NLuint i;
-    __nl_assert(__nlCurrentContext->alloc_x);
-    __nl_assert(__nlCurrentContext->alloc_variable);
-    for(i=0; i<__nlCurrentContext->nb_variables; i++) {
-        __NLVariable* v = &(__nlCurrentContext->variable[i]);
-        if(!v->locked) {
-            __nl_assert(v->index < __nlCurrentContext->n);
-            __nlCurrentContext->x[v->index] = v->value;
-        }
-    }
+       NLuint i;
+       __nl_assert(__nlCurrentContext->alloc_x);
+       __nl_assert(__nlCurrentContext->alloc_variable);
+       for(i=0; i<__nlCurrentContext->nb_variables; i++) {
+               __NLVariable* v = &(__nlCurrentContext->variable[i]);
+               if(!v->locked) {
+                       __nl_assert(v->index < __nlCurrentContext->n);
+                       __nlCurrentContext->x[v->index] = v->value;
+               }
+       }
 }
 
 static void __nlVectorToVariables() {
-    NLuint i;
-    __nl_assert(__nlCurrentContext->alloc_x);
-    __nl_assert(__nlCurrentContext->alloc_variable);
-    for(i=0; i<__nlCurrentContext->nb_variables; i++) {
-        __NLVariable* v = &(__nlCurrentContext->variable[i]);
-        if(!v->locked) {
-            __nl_assert(v->index < __nlCurrentContext->n);
-            v->value = __nlCurrentContext->x[v->index];
-        }
-    }
+       NLuint i;
+       __nl_assert(__nlCurrentContext->alloc_x);
+       __nl_assert(__nlCurrentContext->alloc_variable);
+       for(i=0; i<__nlCurrentContext->nb_variables; i++) {
+               __NLVariable* v = &(__nlCurrentContext->variable[i]);
+               if(!v->locked) {
+                       __nl_assert(v->index < __nlCurrentContext->n);
+                       v->value = __nlCurrentContext->x[v->index];
+               }
+       }
 }
 
-
 static void __nlBeginSystem() {
-    __nlTransition(__NL_STATE_INITIAL, __NL_STATE_SYSTEM);
-    __nl_assert(__nlCurrentContext->nb_variables > 0);
-    __nlCurrentContext->variable = __NL_NEW_ARRAY(
-        __NLVariable, __nlCurrentContext->nb_variables
-    );
-    __nlCurrentContext->alloc_variable = NL_TRUE;
+       __nl_assert(__nlCurrentContext->nb_variables > 0);
+
+       if (__nlCurrentContext->solve_again)
+               __nlTransition(__NL_STATE_SYSTEM_SOLVED, __NL_STATE_SYSTEM);
+       else {
+               __nlTransition(__NL_STATE_INITIAL, __NL_STATE_SYSTEM);
+
+               __nlCurrentContext->variable = __NL_NEW_ARRAY(
+                       __NLVariable, __nlCurrentContext->nb_variables
+               );
+               __nlCurrentContext->alloc_variable = NL_TRUE;
+       }
 }
 
 static void __nlEndSystem() {
-    __nlTransition(__NL_STATE_MATRIX_CONSTRUCTED, __NL_STATE_SYSTEM_CONSTRUCTED);    
+       __nlTransition(__NL_STATE_MATRIX_CONSTRUCTED, __NL_STATE_SYSTEM_CONSTRUCTED);   
 }
 
 static void __nlBeginMatrix() {
-    NLuint i;
-    NLuint n = 0;
-    NLenum storage = __NL_ROWS;
-
-    __nlTransition(__NL_STATE_SYSTEM, __NL_STATE_MATRIX);
-
-    for(i=0; i<__nlCurrentContext->nb_variables; i++) {
-        if(!__nlCurrentContext->variable[i].locked) {
-            __nlCurrentContext->variable[i].index = n;
-            n++;
-        } else {
-            __nlCurrentContext->variable[i].index = ~0;
-        }
-    }
-
-    __nlCurrentContext->n = n;
-
-    /* a least squares problem results in a symmetric matrix */
-    if(__nlCurrentContext->least_squares) {
-        __nlCurrentContext->symmetric = NL_TRUE;
-    }
-
-    if(__nlCurrentContext->symmetric) {
-        storage = (storage | __NL_SYMMETRIC);
-    }
-
-    /* SuperLU storage does not support symmetric storage */
-    storage = (storage & ~__NL_SYMMETRIC);
-
-    __nlSparseMatrixConstruct(&__nlCurrentContext->M, n, n, storage);
-    __nlCurrentContext->alloc_M = NL_TRUE;
-
-    __nlCurrentContext->x = __NL_NEW_ARRAY(NLfloat, n);
-    __nlCurrentContext->alloc_x = NL_TRUE;
-    
-    __nlCurrentContext->b = __NL_NEW_ARRAY(NLfloat, n);
-    __nlCurrentContext->alloc_b = NL_TRUE;
-
-    __nlVariablesToVector();
-
-    __nlRowColumnConstruct(&__nlCurrentContext->af);
-    __nlCurrentContext->alloc_af = NL_TRUE;
-    __nlRowColumnConstruct(&__nlCurrentContext->al);
-    __nlCurrentContext->alloc_al = NL_TRUE;
-    __nlRowColumnConstruct(&__nlCurrentContext->xl);
-    __nlCurrentContext->alloc_xl = NL_TRUE;
-
-    __nlCurrentContext->current_row = 0;
+       NLuint i;
+       NLuint n = 0;
+       NLenum storage = __NL_ROWS;
+
+       __nlTransition(__NL_STATE_SYSTEM, __NL_STATE_MATRIX);
+
+       if (!__nlCurrentContext->solve_again) {
+               for(i=0; i<__nlCurrentContext->nb_variables; i++) {
+                       if(!__nlCurrentContext->variable[i].locked)
+                               __nlCurrentContext->variable[i].index = n++;
+                       else
+                               __nlCurrentContext->variable[i].index = ~0;
+               }
+
+               __nlCurrentContext->n = n;
+
+               /* a least squares problem results in a symmetric matrix */
+               if(__nlCurrentContext->least_squares)
+                       __nlCurrentContext->symmetric = NL_TRUE;
+
+               if(__nlCurrentContext->symmetric)
+                       storage = (storage | __NL_SYMMETRIC);
+
+               /* SuperLU storage does not support symmetric storage */
+               storage = (storage & ~__NL_SYMMETRIC);
+
+               __nlSparseMatrixConstruct(&__nlCurrentContext->M, n, n, storage);
+               __nlCurrentContext->alloc_M = NL_TRUE;
+
+               __nlCurrentContext->x = __NL_NEW_ARRAY(NLfloat, n);
+               __nlCurrentContext->alloc_x = NL_TRUE;
+               
+               __nlCurrentContext->b = __NL_NEW_ARRAY(NLfloat, n);
+               __nlCurrentContext->alloc_b = NL_TRUE;
+       }
+       else {
+               /* need to recompute b only, A is not constructed anymore */
+               __NL_CLEAR_ARRAY(NLfloat, __nlCurrentContext->b, __nlCurrentContext->n);
+       }
+
+       __nlVariablesToVector();
+
+       __nlRowColumnConstruct(&__nlCurrentContext->af);
+       __nlCurrentContext->alloc_af = NL_TRUE;
+       __nlRowColumnConstruct(&__nlCurrentContext->al);
+       __nlCurrentContext->alloc_al = NL_TRUE;
+
+       __nlCurrentContext->current_row = 0;
 }
 
 static void __nlEndMatrix() {
-    __nlTransition(__NL_STATE_MATRIX, __NL_STATE_MATRIX_CONSTRUCTED);    
-    
-    __nlRowColumnDestroy(&__nlCurrentContext->af);
-    __nlCurrentContext->alloc_af = NL_FALSE;
-    __nlRowColumnDestroy(&__nlCurrentContext->al);
-    __nlCurrentContext->alloc_al = NL_FALSE;
-    __nlRowColumnDestroy(&__nlCurrentContext->xl);
-    __nlCurrentContext->alloc_al = NL_FALSE;
-    
+       __nlTransition(__NL_STATE_MATRIX, __NL_STATE_MATRIX_CONSTRUCTED);       
+       
+       __nlRowColumnDestroy(&__nlCurrentContext->af);
+       __nlCurrentContext->alloc_af = NL_FALSE;
+       __nlRowColumnDestroy(&__nlCurrentContext->al);
+       __nlCurrentContext->alloc_al = NL_FALSE;
+       
 #if 0
-    if(!__nlCurrentContext->least_squares) {
-        __nl_assert(
-            __nlCurrentContext->current_row == 
-            __nlCurrentContext->n
-        );
-    }
+       if(!__nlCurrentContext->least_squares) {
+               __nl_assert(
+                       __nlCurrentContext->current_row == 
+                       __nlCurrentContext->n
+               );
+       }
 #endif
 }
 
 static void __nlBeginRow() {
-    __nlTransition(__NL_STATE_MATRIX, __NL_STATE_ROW);
-    __nlRowColumnZero(&__nlCurrentContext->af);
-    __nlRowColumnZero(&__nlCurrentContext->al);
-    __nlRowColumnZero(&__nlCurrentContext->xl);
-}
-
-static void __nlScaleRow(NLfloat s) {
-    __NLRowColumn*    af = &__nlCurrentContext->af;
-    __NLRowColumn*    al = &__nlCurrentContext->al;
-    NLuint nf            = af->size;
-    NLuint nl            = al->size;
-    NLuint i;
-    for(i=0; i<nf; i++) {
-        af->coeff[i].value *= s;
-    }
-    for(i=0; i<nl; i++) {
-        al->coeff[i].value *= s;
-    }
-    __nlCurrentContext->right_hand_side *= s;
-}
-
-static void __nlNormalizeRow(NLfloat weight) {
-    __NLRowColumn*    af = &__nlCurrentContext->af;
-    __NLRowColumn*    al = &__nlCurrentContext->al;
-    NLuint nf            = af->size;
-    NLuint nl            = al->size;
-    NLuint i;
-    NLfloat norm = 0.0;
-    for(i=0; i<nf; i++) {
-        norm += af->coeff[i].value * af->coeff[i].value;
-    }
-    for(i=0; i<nl; i++) {
-        norm += al->coeff[i].value * al->coeff[i].value;
-    }
-    norm = sqrt(norm);
-    __nlScaleRow(weight / norm);
+       __nlTransition(__NL_STATE_MATRIX, __NL_STATE_ROW);
+       __nlRowColumnZero(&__nlCurrentContext->af);
+       __nlRowColumnZero(&__nlCurrentContext->al);
 }
 
 static void __nlEndRow() {
-    __NLRowColumn*    af = &__nlCurrentContext->af;
-    __NLRowColumn*    al = &__nlCurrentContext->al;
-    __NLRowColumn*    xl = &__nlCurrentContext->xl;
-    __NLSparseMatrix* M  = &__nlCurrentContext->M;
-    NLfloat* b        = __nlCurrentContext->b;
-    NLuint nf          = af->size;
-    NLuint nl          = al->size;
-    NLuint current_row = __nlCurrentContext->current_row;
-    NLuint i;
-    NLuint j;
-    NLfloat S;
-    __nlTransition(__NL_STATE_ROW, __NL_STATE_MATRIX);
-
-    if(__nlCurrentContext->normalize_rows) {
-        __nlNormalizeRow(__nlCurrentContext->row_scaling);
-    } else {
-        __nlScaleRow(__nlCurrentContext->row_scaling);
-    }
-
-    if(__nlCurrentContext->least_squares) {
-        for(i=0; i<nf; i++) {
-            for(j=0; j<nf; j++) {
-                __nlSparseMatrixAdd(
-                    M, af->coeff[i].index, af->coeff[j].index,
-                    af->coeff[i].value * af->coeff[j].value
-                );
-            }
-        }
-        S = -__nlCurrentContext->right_hand_side;
-        for(j=0; j<nl; j++) {
-            S += al->coeff[j].value * xl->coeff[j].value;
-        }
-        for(i=0; i<nf; i++) {
-            b[ af->coeff[i].index ] -= af->coeff[i].value * S;
-        }
-    } else {
-        for(i=0; i<nf; i++) {
-            __nlSparseMatrixAdd(
-                M, current_row, af->coeff[i].index, af->coeff[i].value
-            );
-        }
-        b[current_row] = -__nlCurrentContext->right_hand_side;
-        for(i=0; i<nl; i++) {
-            b[current_row] -= al->coeff[i].value * xl->coeff[i].value;
-        }
-    }
-    __nlCurrentContext->current_row++;
-    __nlCurrentContext->right_hand_side = 0.0;    
-    __nlCurrentContext->row_scaling     = 1.0;
+       __NLRowColumn*  af = &__nlCurrentContext->af;
+       __NLRowColumn*  al = &__nlCurrentContext->al;
+       __NLSparseMatrix* M  = &__nlCurrentContext->M;
+       NLfloat* b              = __nlCurrentContext->b;
+       NLuint nf                 = af->size;
+       NLuint nl                 = al->size;
+       NLuint current_row = __nlCurrentContext->current_row;
+       NLuint i;
+       NLuint j;
+       NLfloat S;
+       __nlTransition(__NL_STATE_ROW, __NL_STATE_MATRIX);
+
+       if(__nlCurrentContext->least_squares) {
+               if (!__nlCurrentContext->solve_again) {
+                       for(i=0; i<nf; i++) {
+                               for(j=0; j<nf; j++) {
+                                       __nlSparseMatrixAdd(
+                                               M, af->coeff[i].index, af->coeff[j].index,
+                                               af->coeff[i].value * af->coeff[j].value
+                                       );
+                               }
+                       }
+               }
+
+               S = -__nlCurrentContext->right_hand_side;
+               for(j=0; j<nl; j++)
+                       S += al->coeff[j].value;
+
+               for(i=0; i<nf; i++)
+                       b[ af->coeff[i].index ] -= af->coeff[i].value * S;
+       } else {
+               if (!__nlCurrentContext->solve_again) {
+                       for(i=0; i<nf; i++) {
+                               __nlSparseMatrixAdd(
+                                       M, current_row, af->coeff[i].index, af->coeff[i].value
+                               );
+                       }
+               }
+               b[current_row] = -__nlCurrentContext->right_hand_side;
+               for(i=0; i<nl; i++) {
+                       b[current_row] -= al->coeff[i].value;
+               }
+       }
+       __nlCurrentContext->current_row++;
+       __nlCurrentContext->right_hand_side = 0.0;      
 }
 
 void nlMatrixAdd(NLuint row, NLuint col, NLfloat value)
 {
-    __NLSparseMatrix* M  = &__nlCurrentContext->M;
-    __nlCheckState(__NL_STATE_MATRIX);
-    __nl_range_assert(row, 0, __nlCurrentContext->n - 1);
-    __nl_range_assert(col, 0, __nlCurrentContext->nb_variables - 1);
+       __NLSparseMatrix* M  = &__nlCurrentContext->M;
+       __nlCheckState(__NL_STATE_MATRIX);
+       __nl_range_assert(row, 0, __nlCurrentContext->n - 1);
+       __nl_range_assert(col, 0, __nlCurrentContext->nb_variables - 1);
        __nl_assert(!__nlCurrentContext->least_squares);
 
        __nlSparseMatrixAdd(M, row, col, value);
@@ -952,226 +906,264 @@ void nlMatrixAdd(NLuint row, NLuint col, NLfloat value)
 
 void nlRightHandSideAdd(NLuint index, NLfloat value)
 {
-    NLfloat* b = __nlCurrentContext->b;
+       NLfloat* b = __nlCurrentContext->b;
 
-    __nlCheckState(__NL_STATE_MATRIX);
-    __nl_range_assert(index, 0, __nlCurrentContext->n - 1);
+       __nlCheckState(__NL_STATE_MATRIX);
+       __nl_range_assert(index, 0, __nlCurrentContext->n - 1);
        __nl_assert(!__nlCurrentContext->least_squares);
 
        b[index] += value;
 }
 
 void nlCoefficient(NLuint index, NLfloat value) {
-    __NLVariable* v;
+       __NLVariable* v;
        unsigned int zero= 0;
-    __nlCheckState(__NL_STATE_ROW);
-    __nl_range_assert(index, zero, __nlCurrentContext->nb_variables - 1);
-    v = &(__nlCurrentContext->variable[index]);
-    if(v->locked) {
-        __nlRowColumnAppend(&(__nlCurrentContext->al), 0, value);
-        __nlRowColumnAppend(&(__nlCurrentContext->xl), 0, v->value);
-    } else {
-        __nlRowColumnAppend(&(__nlCurrentContext->af), v->index, value);
-    }
+       __nlCheckState(__NL_STATE_ROW);
+       __nl_range_assert(index, zero, __nlCurrentContext->nb_variables - 1);
+       v = &(__nlCurrentContext->variable[index]);
+       if(v->locked)
+               __nlRowColumnAppend(&(__nlCurrentContext->al), 0, value*v->value);
+       else
+               __nlRowColumnAppend(&(__nlCurrentContext->af), v->index, value);
 }
 
 void nlBegin(NLenum prim) {
-    switch(prim) {
-    case NL_SYSTEM: {
-        __nlBeginSystem();
-    } break;
-    case NL_MATRIX: {
-        __nlBeginMatrix();
-    } break;
-    case NL_ROW: {
-        __nlBeginRow();
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    }
-    }
+       switch(prim) {
+       case NL_SYSTEM: {
+               __nlBeginSystem();
+       } break;
+       case NL_MATRIX: {
+               __nlBeginMatrix();
+       } break;
+       case NL_ROW: {
+               __nlBeginRow();
+       } break;
+       default: {
+               __nl_assert_not_reached;
+       }
+       }
 }
 
 void nlEnd(NLenum prim) {
-    switch(prim) {
-    case NL_SYSTEM: {
-        __nlEndSystem();
-    } break;
-    case NL_MATRIX: {
-        __nlEndMatrix();
-    } break;
-    case NL_ROW: {
-        __nlEndRow();
-    } break;
-    default: {
-        __nl_assert_not_reached;
-    }
-    }
+       switch(prim) {
+       case NL_SYSTEM: {
+               __nlEndSystem();
+       } break;
+       case NL_MATRIX: {
+               __nlEndMatrix();
+       } break;
+       case NL_ROW: {
+               __nlEndRow();
+       } break;
+       default: {
+               __nl_assert_not_reached;
+       }
+       }
 }
 
 /************************************************************************/
 /* SuperLU wrapper */
 
-/* Note: SuperLU is difficult to call, but it is worth it.    */
+/* Note: SuperLU is difficult to call, but it is worth it.     */
 /* Here is a driver inspired by A. Sheffer's "cow flattener". */
-static NLboolean __nlSolve_SUPERLU( NLboolean do_perm) {
-
-    /* OpenNL Context */
-    __NLSparseMatrix* M  = &(__nlCurrentContext->M);
-    NLfloat* b          = __nlCurrentContext->b;
-    NLfloat* x          = __nlCurrentContext->x;
-
-    /* Compressed Row Storage matrix representation */
-    NLuint    n      = __nlCurrentContext->n;
-    NLuint    nnz    = __nlSparseMatrixNNZ(M); /* Number of Non-Zero coeffs */
-    NLint*    xa     = __NL_NEW_ARRAY(NLint, n+1);
-    NLfloat* rhs    = __NL_NEW_ARRAY(NLfloat, n);
-    NLfloat* a      = __NL_NEW_ARRAY(NLfloat, nnz);
-    NLint*    asub   = __NL_NEW_ARRAY(NLint, nnz);
-
-    /* Permutation vector */
-    NLint*    perm_r  = __NL_NEW_ARRAY(NLint, n);
-    NLint*    perm    = __NL_NEW_ARRAY(NLint, n);
-
-    /* SuperLU variables */
-    SuperMatrix A, B; /* System       */
-    SuperMatrix L, U; /* Inverse of A */
-    NLint info;       /* status code  */
-    DNformat *vals = NULL; /* access to result */
-    float *rvals  = NULL; /* access to result */
-
-    /* SuperLU options and stats */
-    superlu_options_t options;
-    SuperLUStat_t     stat;
-
-
-    /* Temporary variables */
-    __NLRowColumn* Ri = NULL;
-    NLuint         i,jj,count;
-    
-    __nl_assert(!(M->storage & __NL_SYMMETRIC));
-    __nl_assert(M->storage & __NL_ROWS);
-    __nl_assert(M->m == M->n);
-    
-    
-    /*
-     * Step 1: convert matrix M into SuperLU compressed column 
-     *   representation.
-     * -------------------------------------------------------
-     */
-
-    count = 0;
-    for(i=0; i<n; i++) {
-        Ri = &(M->row[i]);
-        xa[i] = count;
-        for(jj=0; jj<Ri->size; jj++) {
-            a[count]    = Ri->coeff[jj].value;
-            asub[count] = Ri->coeff[jj].index;
-            count++;
-        }
-    }
-    xa[n] = nnz;
-
-    /* Save memory for SuperLU */
-    __nlSparseMatrixClear(M);
-
-
-    /*
-     * Rem: symmetric storage does not seem to work with
-     * SuperLU ... (->deactivated in main SLS::Solver driver)
-     */
-    sCreate_CompCol_Matrix(
-        &A, n, n, nnz, a, asub, xa, 
-        SLU_NR,              /* Row_wise, no supernode */
-        SLU_S,               /* floats                */ 
-        SLU_GE               /* general storage        */
-    );
-
-    /* Step 2: create vector */
-    sCreate_Dense_Matrix(
-        &B, n, 1, b, n, 
-        SLU_DN, /* Fortran-type column-wise storage */
-        SLU_S,  /* floats                          */
-        SLU_GE  /* general                          */
-    );
-            
-
-    /* Step 3: get permutation matrix 
-     * ------------------------------
-     * com_perm: 0 -> no re-ordering
-     *           1 -> re-ordering for A^t.A
-     *           2 -> re-ordering for A^t+A
-     *           3 -> approximate minimum degree ordering
-     */
-    get_perm_c(do_perm ? 3 : 0, &A, perm);
-
-    /* Step 4: call SuperLU main routine
-     * ---------------------------------
-     */
-
-    set_default_options(&options);
-    options.ColPerm = MY_PERMC;
-    StatInit(&stat);
-
-    sgssv(&options, &A, perm, perm_r, &L, &U, &B, &stat, &info);
-
-    /* Step 5: get the solution
-     * ------------------------
-     * Fortran-type column-wise storage
-     */
-    vals = (DNformat*)B.Store;
-    rvals = (float*)(vals->nzval);
-    if(info == 0) {
-        for(i = 0; i <  n; i++){
-            x[i] = rvals[i];
-        }
-    }
-
-    /* Step 6: cleanup
-     * ---------------
-     */
-
-    /*
-     *  For these two ones, only the "store" structure
-     * needs to be deallocated (the arrays have been allocated
-     * by us).
-     */
-    Destroy_SuperMatrix_Store(&A);
-    Destroy_SuperMatrix_Store(&B);
-
-    
-    /*
-     *   These ones need to be fully deallocated (they have been
-     * allocated by SuperLU).
-     */
-    Destroy_SuperNode_Matrix(&L);
-    Destroy_CompCol_Matrix(&U);
-
-    StatFree(&stat);
-
-    __NL_DELETE_ARRAY(xa);
-    __NL_DELETE_ARRAY(rhs);
-    __NL_DELETE_ARRAY(a);
-    __NL_DELETE_ARRAY(asub);
-    __NL_DELETE_ARRAY(perm_r);
-    __NL_DELETE_ARRAY(perm);
-
-    return (info == 0);
+static NLboolean __nlFactorize_SUPERLU(__NLContext *context, NLint *permutation) {
+
+       /* OpenNL Context */
+       __NLSparseMatrix* M = &(context->M);
+       NLuint n = context->n;
+       NLuint nnz = __nlSparseMatrixNNZ(M); /* number of non-zero coeffs */
+
+       /* Compressed Row Storage matrix representation */
+       NLint   *xa             = __NL_NEW_ARRAY(NLint, n+1);
+       NLfloat *rhs    = __NL_NEW_ARRAY(NLfloat, n);
+       NLfloat *a              = __NL_NEW_ARRAY(NLfloat, nnz);
+       NLint   *asub   = __NL_NEW_ARRAY(NLint, nnz);
+       NLint   *etree  = __NL_NEW_ARRAY(NLint, n);
+
+       /* SuperLU variables */
+       SuperMatrix At, AtP;
+       NLint info, panel_size, relax;
+       superlu_options_t options;
+
+       /* Temporary variables */
+       __NLRowColumn* Ri = NULL;
+       NLuint i, jj, count;
+       
+       __nl_assert(!(M->storage & __NL_SYMMETRIC));
+       __nl_assert(M->storage & __NL_ROWS);
+       __nl_assert(M->m == M->n);
+       
+       /* Convert M to compressed column format */
+       for(i=0, count=0; i<n; i++) {
+               __NLRowColumn *Ri = M->row + i;
+               xa[i] = count;
+
+               for(jj=0; jj<Ri->size; jj++, count++) {
+                       a[count] = Ri->coeff[jj].value;
+                       asub[count] = Ri->coeff[jj].index;
+               }
+       }
+       xa[n] = nnz;
+
+       /* Free M, don't need it anymore at this point */
+       __nlSparseMatrixClear(M);
+
+       /* Create superlu A matrix transposed */
+       sCreate_CompCol_Matrix(
+               &At, n, n, nnz, a, asub, xa, 
+               SLU_NC,         /* Colum wise, no supernode */
+               SLU_S,          /* floats */ 
+               SLU_GE          /* general storage */
+       );
+
+       /* Set superlu options */
+       set_default_options(&options);
+       options.ColPerm = MY_PERMC;
+       options.Fact = DOFACT;
+
+       StatInit(&(context->slu.stat));
+
+       panel_size = sp_ienv(1); /* sp_ienv give us the defaults */
+       relax = sp_ienv(2);
+
+       /* Compute permutation and permuted matrix */
+       context->slu.perm_r = __NL_NEW_ARRAY(NLint, n);
+       context->slu.perm_c = __NL_NEW_ARRAY(NLint, n);
+
+       if ((permutation == NULL) || (*permutation == -1)) {
+               get_perm_c(3, &At, context->slu.perm_c);
+
+               if (permutation)
+                       memcpy(permutation, context->slu.perm_c, sizeof(NLint)*n);
+       }
+       else
+               memcpy(context->slu.perm_c, permutation, sizeof(NLint)*n);
+
+       sp_preorder(&options, &At, context->slu.perm_c, etree, &AtP);
+
+       /* Decompose into L and U */
+       sgstrf(&options, &AtP, relax, panel_size,
+               etree, NULL, 0, context->slu.perm_c, context->slu.perm_r,
+               &(context->slu.L), &(context->slu.U), &(context->slu.stat), &info);
+
+       /* Cleanup */
+
+       Destroy_SuperMatrix_Store(&At);
+       Destroy_SuperMatrix_Store(&AtP);
+
+       __NL_DELETE_ARRAY(etree);
+       __NL_DELETE_ARRAY(xa);
+       __NL_DELETE_ARRAY(rhs);
+       __NL_DELETE_ARRAY(a);
+       __NL_DELETE_ARRAY(asub);
+
+       context->slu.alloc_slu = NL_TRUE;
+
+       return (info == 0);
+}
+
+static NLboolean __nlInvert_SUPERLU(__NLContext *context) {
+
+       /* OpenNL Context */
+       NLfloat* b = context->b;
+       NLfloat* x = context->x;
+       NLuint n = context->n;
+
+       /* SuperLU variables */
+       SuperMatrix B;
+       NLint info;
+
+       /* Create superlu array for B */
+       sCreate_Dense_Matrix(
+               &B, n, 1, b, n, 
+               SLU_DN, /* Fortran-type column-wise storage */
+               SLU_S,  /* floats                                                 */
+               SLU_GE  /* general                                                */
+       );
+
+       /* Forward/Back substitution to compute x */
+       sgstrs(TRANS, &(context->slu.L), &(context->slu.U),
+               context->slu.perm_c, context->slu.perm_r, &B,
+               &(context->slu.stat), &info);
+
+       if(info == 0)
+               memcpy(x, ((DNformat*)B.Store)->nzval, sizeof(*x)*n);
+
+       Destroy_SuperMatrix_Store(&B);
+
+       return (info == 0);
+}
+
+static void __nlFree_SUPERLU(__NLContext *context) {
+
+       Destroy_SuperNode_Matrix(&(context->slu.L));
+       Destroy_CompCol_Matrix(&(context->slu.U));
+
+       StatFree(&(context->slu.stat));
+
+       __NL_DELETE_ARRAY(context->slu.perm_r);
+       __NL_DELETE_ARRAY(context->slu.perm_c);
+
+       context->slu.alloc_slu = NL_FALSE;
 }
 
+void nlPrintMatrix(void) {
+       __NLSparseMatrix* M  = &(__nlCurrentContext->M);
+       float *b = __nlCurrentContext->b;
+       NLuint i, jj, k;
+       NLuint n = __nlCurrentContext->n;
+       __NLRowColumn* Ri = NULL;
+       float *value = malloc(sizeof(*value)*n);
+
+       printf("A:\n");
+       for(i=0; i<n; i++) {
+               Ri = &(M->row[i]);
+
+               memset(value, 0.0, sizeof(*value)*n);
+               for(jj=0; jj<Ri->size; jj++)
+                       value[Ri->coeff[jj].index] = Ri->coeff[jj].value;
+
+               for (k = 0; k<n; k++)
+                       printf("%.3f ", value[k]);
+               printf("\n");
+       }
+
+       printf("b:\n");
+       for(i=0; i<n; i++)
+               printf("%f ", b[i]);
+       printf("\n");
+
+       free(value);
+}
 
 /************************************************************************/
 /* nlSolve() driver routine */
 
-NLboolean nlSolve(void) {
-    NLboolean result = NL_TRUE;
+NLboolean nlSolveAdvanced(NLint *permutation, NLboolean solveAgain) {
+       NLboolean result = NL_TRUE;
+
+       __nlCheckState(__NL_STATE_SYSTEM_CONSTRUCTED);
+
+       if (!__nlCurrentContext->solve_again)
+               result = __nlFactorize_SUPERLU(__nlCurrentContext, permutation);
+
+       if (result) {
+               result = __nlInvert_SUPERLU(__nlCurrentContext);
 
-    __nlCheckState(__NL_STATE_SYSTEM_CONSTRUCTED);
-    result = __nlSolve_SUPERLU(NL_TRUE);
+               if (result) {
+                       __nlVectorToVariables();
 
-    __nlVectorToVariables();
-    __nlTransition(__NL_STATE_SYSTEM_CONSTRUCTED, __NL_STATE_SOLVED);
+                       if (solveAgain)
+                               __nlCurrentContext->solve_again = NL_TRUE;
+
+                       __nlTransition(__NL_STATE_SYSTEM_CONSTRUCTED, __NL_STATE_SYSTEM_SOLVED);
+               }
+       }
+
+       return result;
+}
 
-    return result;
+NLboolean nlSolve() {
+       return nlSolveAdvanced(NULL, NL_FALSE);
 }
 
index b6134b5d805db97204934854e205b9ce46003f15..ef99a25239c64eb39f645d60edc8b9ac9b6fd33c 100644 (file)
@@ -70,7 +70,7 @@ LIB32=link.exe -lib
 MTL=midl.exe
 LINK32=link.exe -lib
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\source\blender\imbuf\intern" /I "..\..\..\source\blender\quicktime" /I "..\..\..\source\blender\blenloader" /I "..\..\..\source\blender\render\extern\include" /I "..\..\..\..\lib\windows\guardedalloc\include" /I "..\..\..\source\blender\avi" /I "..\..\..\source\blender\imbuf" /I "..\..\..\source\blender\blenkernel" /I "..\..\..\source\blender\blenlib" /I "..\..\..\source\blender\include" /I "..\..\..\..\lib\windows\jpeg\include" /I "..\..\..\..\lib\windows\zlib\include" /I "..\..\..\..\lib\windows\png\include" /I "..\..\..\source\blender\makesdna" /I "..\..\..\..\lib\windows\tiff\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "WITH_QUICKTIME" /YX /FD /I /GZ "..\..\..\source\blender\imbuf" /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\source\blender\imbuf\intern" /I "..\..\..\source\blender\quicktime" /I "..\..\..\source\blender\blenloader" /I "..\..\..\source\blender\render\extern\include" /I "..\..\..\..\lib\windows\guardedalloc\include" /I "..\..\..\source\blender\avi" /I "..\..\..\source\blender\imbuf" /I "..\..\..\source\blender\blenkernel" /I "..\..\..\source\blender\blenlib" /I "..\..\..\source\blender\include" /I "..\..\..\..\lib\windows\jpeg\include" /I "..\..\..\..\lib\windows\zlib\include" /I "..\..\..\..\lib\windows\png\include" /I "..\..\..\source\blender\makesdna..\..\..\lib\windows\\" /I "..\..\..\..\lib\windows\tiff\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "WITH_QUICKTIME" /YX /FD /I /GZ "..\..\..\source\blender\imbuf" /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index e8a8580bb590551d6e77f5f12602ff786a4f220e..7da591109f5c53604035edb1ab2308a3012c3759 100644 (file)
@@ -63,7 +63,6 @@ ECHO Copying required 3rd party dlls...
 XCOPY /Y ..\..\..\lib\windows\python\lib\python24.dll ..\..\bin
 XCOPY /Y ..\..\..\lib\windows\gettext\lib\*.dll ..\..\bin
 XCOPY /Y ..\..\..\lib\windows\sdl\lib\*.dll ..\..\bin
-XCOPY /Y ..\..\..\lib\windows\tiff\lib\libtiff.dll ..\..\bin
 ECHO Copying language folder
 ECHO Done
 "/>
@@ -141,7 +140,6 @@ XCOPY /Y ..\..\..\lib\windows\gettext\lib\*.dll ..\..\bin\debug
 XCOPY /Y ..\..\..\lib\windows\sdl\lib\*.dll ..\..\bin\debug
 XCOPY /Y ..\..\..\lib\windows\python\lib\python24_d.dll ..\..\bin\debug
 XCOPY /Y ..\..\..\lib\windows\CRTL\lib\msvcrtd.dll ..\..\bin\debug
-XCOPY /Y ..\..\..\lib\windows\tiff\lib\libtiff.dll ..\..\bin\debug
 ECHO Copying language folder
 IF NOT EXIST ..\..\bin\debug\.blender MKDIR ..\..\bin\debug\.blender
 XCOPY /Y ..\..\bin\.blender ..\..\bin\debug\.blender /E
index 2ce865373dc3ba25f1adfbb80d4a150ce02523bc..c608b3044eae7fbefe09265b0e0a57d6fd5b1d68 100644 (file)
@@ -21,7 +21,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\tiff\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
                                PreprocessorDefinitions="_DEBUG,WIN32,_LIB,WITH_QUICKTIME"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
@@ -73,7 +73,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\tiff\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
                                PreprocessorDefinitions="_DEBUG,WIN32,_LIB"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="3"
                        <Tool
                                Name="VCCLCompilerTool"
                                InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\tiff\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
                                PreprocessorDefinitions="NDEBUG,WIN32,_LIB,WITH_QUICKTIME"
                                StringPooling="TRUE"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCCLCompilerTool"
                                InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\tiff\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
                                PreprocessorDefinitions="NDEBUG,WIN32,_LIB,WITH_QUICKTIME"
                                StringPooling="TRUE"
                                RuntimeLibrary="0"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\tiff\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
                                PreprocessorDefinitions="_DEBUG,WIN32,_LIB,WITH_QUICKTIME"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="1"
                        <Tool
                                Name="VCCLCompilerTool"
                                InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\tiff\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
+                               AdditionalIncludeDirectories="..\..\..\..\lib\windows\jpeg\include;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\png\include;..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenloader;..\..\..\source\blender\makesdna;..\..\..\source\blender\imbuf\intern;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include"
                                PreprocessorDefinitions="NDEBUG,WIN32,_LIB,WITH_QUICKTIME"
                                StringPooling="TRUE"
                                RuntimeLibrary="0"
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\divers.c">
                        </File>
-                       <File
-                               RelativePath="..\..\..\source\blender\imbuf\intern\dynlibtiff.c">
-                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\filter.c">
                        </File>
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\targa.c">
                        </File>
-                       <File
-                               RelativePath="..\..\..\source\blender\imbuf\intern\tiff.c">
-                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\util.c">
                        </File>
                <Filter
                        Name="Header Files"
                        Filter="h;hpp;hxx;hm;inl">
-                       <File
-                               RelativePath="..\..\..\source\blender\imbuf\intern\dynlibtiff.h">
-                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\IMB_allocimbuf.h">
                        </File>
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\IMB_targa.h">
                        </File>
-                       <File
-                               RelativePath="..\..\..\source\blender\imbuf\intern\IMB_tiff.h">
-                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\imbuf\intern\imbuf.h">
                        </File>
index d9f7af1bdef6045366aa8fb8f393fc25c4ba6393..31a7f04dbb07b20f5c2fafdb5d6cdf1096dd51d9 100644 (file)
@@ -55,7 +55,14 @@ all:
       ifeq ($(CPU),alpha)
        @$(MAKE) pkg TYPE="" TAR="tar cf" EXT1=".tar" \
            COMPRESS="gzip -f --best" EXT2=".gz"
-      else
+      endif
+      ifeq ($(CPU),i386)
+       @$(MAKE) pkg TYPE="" TAR="tar cf" EXT1=".tar" \
+           COMPRESS="gzip -f --best" EXT2=".gz"
+       @$(MAKE) pkg TYPE="-static" TAR="tar cf" EXT1=".tar" \
+           COMPRESS="gzip -f --best" EXT2=".gz"
+      endif
+      ifeq ($(CPU),powerpc)
        @$(MAKE) pkg TYPE="" TAR="tar cf" EXT1=".tar" \
            COMPRESS="gzip -f --best" EXT2=".gz"
        @$(MAKE) pkg TYPE="-static" TAR="tar cf" EXT1=".tar" \
index 3a0169f2dfb3050af484dedf794a55cbc3e5292c..6025cef7f0e11f1e41da9a25e143542dbb005928 100644 (file)
@@ -123,7 +123,7 @@ def parall_coord(old, dir):
        return (nco,vec)
 
 def get_vert(old, dir):
-       """ Look in NV if a vertex corresponding to the vertex old and the
+       """ Look in NV if a vertice corresponding to the vertex old and the
        direction dir already exists, and create one otherwise""" 
        (nco, vec) = parall_coord(old, dir)
        v = is_in_NV(old,vec)
@@ -315,7 +315,7 @@ def make_corners():
                        is_in_v = lambda x:x in V
                        eed =  [filter(is_in_v, l) for l in q]
                        #
-                       # We will add the edges coming from faces where only one vertex is selected.
+                       # We will add the edges coming from faces where only one vertice is selected.
                        # They are stocked in NC.
                        if v in NC.keys():
                                eed = eed+NC[v]
index 05f40f018dc71af8ba678816eb70908bba8362ab..17ce01c0cabc871001c9d1b19a5c3d736c3601ef 100644 (file)
@@ -2,14 +2,14 @@
 
 """
 Name: 'Motion Capture (.bvh)...'
-Blender: 239
+Blender: 236
 Group: 'Import'
 Tip: 'Import a (.bvh) motion capture file'
 """
 
 __author__ = "Campbell Barton"
-__url__ = ("blender", "elysiun")
-__version__ = "1.0.4 05/12/04"
+__url__ = ("blender", "elysiun", "http://jmsoler.free.fr/util/blenderfile/py/bvh_import.py")
+__version__ = "1.0.2 04/12/28"
 
 __bpydoc__ = """\
 This script imports BVH motion capture data to Blender.
@@ -21,52 +21,32 @@ Missing:<br>
 Known issues:<br>
 
 Notes:<br>
-        Jean-Michel Soler improved importer to support Poser 3.01 files;<br>
-        Jean-Baptiste Perin wrote a script to create an armature out of the
+   Jean-Michel Soler improved importer to support Poser 3.01 files;<br>
+   Jean-Baptiste Perin wrote a script to create an armature out of the
 Empties created by this importer, it's in the Scripts window -> Scripts -> Animation menu.
 """
 
 # $Id$
 #
 
-#===============================================#
-# BVH Import script 1.05 patched by Campbell    #
-# Modified to use Mathutils for matrix math,    #
-# Fixed possible joint naming bug,              #
-# Imports BVH's with bad EOF gracefully         #
-# Fixed duplicate joint names, make them unique #
-# Use \r as well as \n for newlines             #
-# Added suppot for nodes with 0 motion channels #
-# Rotation IPOs never cross more then 180d      #
-#    fixes sub frame tweening and time scaling  #
-# 5x overall speedup.                           #
-# 06/12/2005,                                   #      
-#===============================================#
-
-#===============================================#
-# BVH Import script 1.04 patched by jms         #
-# Small modif for blender 2.40                  #
-# 04/12/2005,                                   #      
-#===============================================#
-
 #===============================================#
 # BVH Import script 1.03 patched by Campbell    #
 # Small optimizations and scale input           #
-# 01/01/2005,                                   #      
+# 01/01/2005,                                   #  
 #===============================================#
 
 #===============================================#
 # BVH Import script 1.02 patched by Jm Soler    #
-# to the Poser 3.01 bvh file                    #
-# 28/12/2004,                                   #      
+# to the Poser 3.01 bvh file                    # 
+# 28/12/2004,                                   #  
 #===============================================#
 
 #===============================================#
 # BVH Import script 1.0 by Campbell Barton      #
 # 25/03/2004, euler rotation code taken from    #
 # Reevan Mckay's BVH import script v1.1         #
-# if you have any questions about this scrip.   #
-# email me cbarton@metavr.com                   #
+# if you have any questions about this script   #
+# email me ideasman@linuxmail.org               #
 #===============================================#
 
 #===============================================#
@@ -77,7 +57,7 @@ Empties created by this importer, it's in the Scripts window -> Scripts -> Anima
 #===============================================#
 
 # -------------------------------------------------------------------------- 
-# BVH Import v1.05 by Campbell Barton (AKA Ideasman) 
+# BVH Import v0.9 by Campbell Barton (AKA Ideasman) 
 # -------------------------------------------------------------------------- 
 # ***** BEGIN GPL LICENSE BLOCK ***** 
 # 
@@ -88,410 +68,457 @@ Empties created by this importer, it's in the Scripts window -> Scripts -> Anima
 # 
 # This program 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 
+# 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 this program; if not, write to the Free Software Foundation, 
-# Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA. 
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 # 
 # ***** END GPL LICENCE BLOCK ***** 
 # -------------------------------------------------------------------------- 
 
+
+import string
+import math
 import Blender
 from Blender import Window, Object, Scene, Ipo, Draw
 from Blender.Scene import Render
 
 
-# Attempt to load psyco, speed things up
-try:
-       import psyco
-       psyco.full()    
-       print 'using psyco to speed up BVH importing'
-except:
-       #print 'psyco is not present on this system'
-       pass
-
-
-
-def main():
-       global scale
-       scale = None
-       
-       # Update as we load?
-       debug = 0
-       
-       def getScale():
-               return Draw.PupFloatInput('BVH Scale: ', 0.01, 0.001, 10.0, 0.1, 3)
-       
-       
-       #===============================================#
-       # MAIN FUNCTION - All things are done from here #
-       #===============================================#
-       def loadBVH(filename):
-               global scale
-               print '\nBVH Importer 1.05 by Campbell Barton (Ideasman) - cbarton@metavr.com'
-               
-               objectCurveMapping = {}
-               objectNameMapping = {}
-               objectMotiondataMapping = {}
-               
-               # Here we store the Ipo curves in the order they load.
-               channelCurves = []
-               
-               # Object list
-               # We need this so we can loop through the objects and edit there IPO's 
-               # Chenging there rotation to EULER rotation
-               objectList = []
-               
-               if scale == None:
-                       tempscale = getScale()
-                       if tempscale:
-                               scale = tempscale
-                       else:
-                               scale = 0.01
-               
-               Window.WaitCursor(1)
-               # Unique names, dont reuse any of these names.
-               uniqueObNames = [ob.name for ob in Object.Get()]
-               
-               
-               # FUNCTIONS ====================================#
-               def getUniqueObName(name):
-                       i = 0
-                       newname = name[:min(len(name), 12)] # Concatinate to 12 chars
-                       while newname in uniqueObNames:
-                               newname = name + str(i)
-                               i+=1
-                       return newname
-                       
-               # Change the order rotation is applied.
-               RotationMatrix = Blender.Mathutils.RotationMatrix
-               MATRIX_IDENTITY_3x3 = Blender.Mathutils.Matrix([1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0])
-               def eulerRotate(x,y,z): 
-                       x,y,z = x%360,y%360,z%360 # Clamp all values between 0 and 360, values outside this raise an error.
-                       xmat = RotationMatrix(x,3,'x')
-                       ymat = RotationMatrix(y,3,'y')
-                       zmat = RotationMatrix(z,3,'z')
-                       # Standard BVH multiplication order, apply the rotation in the order Z,X,Y
-                       return (ymat*(xmat * (zmat * MATRIX_IDENTITY_3x3))).toEuler()
-               
-
-               currentFrame = 1 # Set the initial frame to import all data to.
-               
-               #===============================================#
-               # makeJoint: Here we use the node data          #
-               # from the BVA file to create an empty          #
-               #===============================================#
-               BVH2BLEND_TX_NAME = {'Xposition':'LocX','Yposition':'LocY','Zposition':'LocZ','Xrotation':'RotX','Yrotation':'RotY','Zrotation':'RotZ'}
-               def makeJoint(name, parent, offset, channels):
-                       ob = Object.New('Empty', name) # New object, ob is shorter and nicer to use.
-                       
-                       objectNameMapping[name] = ob
-                       scn.link(ob) # place the object in the current scene
-                       ob.sel = 1
-                       
-                       # Make me a child of another empty.
-                       # Vale of None will make the empty a root node (no parent)
-                       if parent[-1]: # != None
-                               obParent = objectNameMapping[parent[-1]] # We use this a bit so refrence it here.
-                               obParent.makeParent([ob], 1, 0) #ojbs, noninverse, 1 = not fast.
-               
-                       # Offset Empty from BVH's initial joint location.
-                       ob.setLocation(offset[0]*scale, offset[1]*scale, offset[2]*scale)
-               
-                       # Add Ipo's for necessary channels
-                       newIpo = Ipo.New('Object', name)
-                       ob.setIpo(newIpo)
-                       obname = ob.name
-                       for channelType in channels:
-                               channelType = BVH2BLEND_TX_NAME[channelType]
-                               curve = newIpo.addCurve(channelType)
-                               curve.setInterpolation('Linear')
-                               objectCurveMapping[(obname, channelType)] = curve
-               
-                       # Add to object list
-                       objectList.append(ob)
-                       
-                       # Redraw if debugging
-                       if debug: Blender.Redraw()
-                       
-                       
-               #===============================================#
-               # makeEnd: Here we make an end node             #
-               # This is needed when adding the last bone      #
-               #===============================================#
-               def makeEnd(parent, offset):
-                       new_name = parent[-1] + '_end'
-                       ob = Object.New('Empty', new_name) # New object, ob is shorter and nicer to use.
-                       objectNameMapping[new_name] = ob
-                       scn.link(ob)
-                       ob.sel = 1
-                       
-                       # Dont check for a parent, an end node MUST have a parent
-                       obParent = objectNameMapping[parent[-1]] # We use this a bit so refrence it here.
-                       obParent.makeParent([ob], 1, 0) #ojbs, noninverse, 1 = not fast.
-               
-                       # Offset Empty
-                       ob.setLocation(offset[0]*scale, offset[1]*scale, offset[2]*scale) 
-                       
-                       # Redraw if debugging
-                       if debug: Blender.Redraw()
-               # END FUNCTION DEFINITIONS ====================================#
-                       
-               
-               
-               
-               time1 = Blender.sys.time()
-               
-               # Get the current scene.
-               scn = Scene.GetCurrent()
-               #context = scn.getRenderingContext()
-               
-               # DeSelect All
-               for ob in scn.getChildren():
-                       ob.sel = 0
-               
-               # File loading stuff
-               # Open the file for importing
-               file = open(filename, 'r')      
-               
-               # Seperate into a list of lists, each line a list of words.
-               lines = file.readlines()
-               # Non standard carrage returns?
-               if len(lines) == 1:
-                       lines = lines[0].split('\r')
-               
-               # Split by whitespace.
-               lines =[ll for ll in [ [w for w in l.split() if w != '\n' ] for l in lines] if ll]
-               # End file loading code
-       
-               
-               
-               # Create Hirachy as empties
-               if lines[0][0] == 'HIERARCHY':
-                       print 'Importing the BVH Hierarchy for:', filename
-               else:
-                       return 'ERROR: This is not a BVH file'
-               
-               # A liniar list of ancestors to keep track of a single objects heratage
-               # at any one time, this is appended and removed, dosent store tree- just a liniar list.
-               # ZERO is a place holder that means we are a root node. (no parents)
-               parent = [None] 
-               
-               #channelList, sync with objectList:  [[channelType1, channelType2...],  [channelType1, channelType2...)]
-               channelList = []
-               channelIndex = -1
-               
-               lineIdx = 0 # An index for the file.
-               while lineIdx < len(lines) -1:
-                       #...
-                       if lines[lineIdx][0] == 'ROOT' or lines[lineIdx][0] == 'JOINT':
-                               
-                               # Join spaces into 1 word with underscores joining it.
-                               if len(lines[lineIdx]) > 2:
-                                       lines[lineIdx][1] = '_'.join(lines[lineIdx][1:])
-                                       lines[lineIdx] = lines[lineIdx][:2]
-                               
-                               # MAY NEED TO SUPPORT MULTIPLE ROOT's HERE!!!, Still unsure weather multiple roots are possible.??
-                               
-                               # Make sure the names are unique- Object names will match joint names exactly and both will be unique.
-                               name = getUniqueObName(lines[lineIdx][1])
-                               uniqueObNames.append(name)
-                               
-                               print '%snode: %s, parent: %s' % (len(parent) * '  ', name,  parent[-1])
-                               
-                               lineIdx += 2 # Incriment to the next line (Offset)
-                               offset = ( float(lines[lineIdx][1]), float(lines[lineIdx][2]), float(lines[lineIdx][3]) )
-                               lineIdx += 1 # Incriment to the next line (Channels)
-                               
-                               # newChannel[Xposition, Yposition, Zposition, Xrotation, Yrotation, Zrotation]
-                               # newChannel references indecies to the motiondata,
-                               # if not assigned then -1 refers to the last value that will be added on loading at a value of zero, this is appended 
-                               # We'll add a zero value onto the end of the MotionDATA so this is always refers to a value.
-                               newChannel = [-1, -1, -1, -1, -1, -1] 
-                               for channel in lines[lineIdx][2:]:
-                                       channelIndex += 1 # So the index points to the right channel
-                                       if channel == 'Xposition':
-                                               newChannel[0] = channelIndex
-                                       elif channel == 'Yposition':
-                                               newChannel[1] = channelIndex
-                                       elif channel == 'Zposition':
-                                               newChannel[2] = channelIndex
-                                       elif channel == 'Xrotation':
-                                               newChannel[3] = channelIndex
-                                       elif channel == 'Yrotation':
-                                               newChannel[4] = channelIndex
-                                       elif channel == 'Zrotation':
-                                               newChannel[5] = channelIndex
-                               
-                               channelList.append(newChannel)
-                               
-                               channels = lines[lineIdx][2:]
-                               
-                               # Call funtion that uses the gatrhered data to make an empty.
-                               makeJoint(name, parent, offset, channels)
-                               
-                               # If we have another child then we can call ourselves a parent, else 
-                               parent.append(name)
-       
-                       # Account for an end node
-                       if lines[lineIdx][0] == 'End' and lines[lineIdx][1] == 'Site': # There is somtimes a name after 'End Site' but we will ignore it.
-                               lineIdx += 2 # Incriment to the next line (Offset)
-                               offset = ( float(lines[lineIdx][1]), float(lines[lineIdx][2]), float(lines[lineIdx][3]) )
-                               makeEnd(parent, offset)
-                               
-                               # Just so we can remove the Parents in a uniform way- End end never has kids
-                               # so this is a placeholder
-                               parent.append(None)
-                       
-                       if len(lines[lineIdx]) == 1 and lines[lineIdx][0] == '}': # == ['}']
-                               parent.pop() # Remove the last item
-                       
-                       #=============================================#
-                       # BVH Structure loaded, Now import motion     #
-                       #=============================================#         
-                       if len(lines[lineIdx]) == 1 and lines[lineIdx][0] == 'MOTION':
-                               print '\nImporting motion data'
-                               lineIdx += 3 # Set the cursor to the first frame
-                               
-                               #=============================================#
-                               # Add a ZERO keyframe, this keeps the rig     #
-                               # so when we export we know where all the     #
-                               # joints start from                           #
-                               #=============================================#
-                               
-                               for obIdx, ob in enumerate(objectList):
-                                       obname = ob.name
-                                       if channelList[obIdx][0] != -1:
-                                               objectCurveMapping[obname, 'LocX'].addBezier((currentFrame,0))
-                                               objectMotiondataMapping[obname, 'LocX'] = []
-                                       if channelList[obIdx][1] != -1:
-                                               objectCurveMapping[obname, 'LocY'].addBezier((currentFrame,0))
-                                               objectMotiondataMapping[obname, 'LocY'] = []
-                                       if channelList[obIdx][2] != -1:
-                                               objectCurveMapping[obname, 'LocZ'].addBezier((currentFrame,0))
-                                               objectMotiondataMapping[obname, 'LocZ'] = []
-                                       if\
-                                       channelList[obIdx][3] != -1 or\
-                                       channelList[obIdx][4] != -1 or\
-                                       channelList[obIdx][5] != -1:
-                                               objectMotiondataMapping[obname, 'RotX'] = []
-                                               objectMotiondataMapping[obname, 'RotY'] = []
-                                               objectMotiondataMapping[obname, 'RotZ'] = []
-                               
-                               #=============================================#
-                               # Loop through frames, each line a frame      #
-                               #=============================================#                 
-                               MOTION_DATA_LINE_LEN = len(lines[lineIdx])
-                               while lineIdx < len(lines):
-                                       line = lines[lineIdx]
-                                       if MOTION_DATA_LINE_LEN != len(line):
-                                               print 'ERROR: Incomplete motion data on line %i, finishing import.' % lineIdx
-                                               break
-                                               
-                                       # Exit loop if we are past the motiondata.
-                                       # Some BVH's have extra tags like 'CONSTRAINTS and MOTIONTAGS'
-                                       # I dont know what they do and I dont care, they'll be ignored here.
-                                       if len(line) < len(objectList):
-                                               print '...ending on unknown tags'
-                                               break
-                                       
-                                       
-                                       currentFrame += 1 # Incriment to next frame
-                                                                       
-                                       #=============================================#
-                                       # Import motion data and assign it to an IPO    #
-                                       #=============================================#
-                                       line.append(0.0) # Use this as a dummy var for objects that dont have a loc/rotate channel.
-                                       
-                                       if debug: Blender.Redraw() 
-                                       for obIdx, ob in enumerate(objectList):
-                                               obname = ob.name
-                                               obChannel = channelList[obIdx] 
-                                               if channelList[obIdx][0] != -1:
-                                                       objectMotiondataMapping[obname, 'LocX'].append((currentFrame, scale * float(  line[obChannel[0]]  )))
-                                                       
-                                               if channelList[obIdx][1] != -1:
-                                                       objectMotiondataMapping[obname, 'LocY'].append((currentFrame, scale * float(  line[obChannel[1]]         )))
-
-                                               if channelList[obIdx][2] != -1:
-                                                       objectMotiondataMapping[obname, 'LocZ'].append((currentFrame, scale * float(  line[obChannel[2]]  )))
-                                               
-                                               if obChannel[3] != -1 or obChannel[4] != -1 or obChannel[5] != -1:                                              
-                                                       x, y, z = eulerRotate(float( line[obChannel[3]] ), float( line[obChannel[4]] ), float( line[obChannel[5]] ))
-                                                       x,y,z = x/10.0, y/10.0, z/10.0 # For IPO's 36 is 360d
-                                                       motionMappingRotX = objectMotiondataMapping[obname, 'RotX']
-                                                       motionMappingRotY = objectMotiondataMapping[obname, 'RotY']
-                                                       motionMappingRotZ = objectMotiondataMapping[obname, 'RotZ']
-                                                       
-                                                       # Make interpolation not cross between 180d, thjis fixes sub frame interpolation and time scaling.
-                                                       # Will go from (355d to 365d) rather then to (355d to 5d) - inbetween these 2 there will now be a correct interpolation.
-                                                       if len(motionMappingRotX) > 1:
-                                                               while (motionMappingRotX[-1][1] - x) > 18: x+=36
-                                                               while (motionMappingRotX[-1][1] - x) < -18: x-=36
-                                                               
-                                                               while (motionMappingRotY[-1][1] - y) > 18: y+=36
-                                                               while (motionMappingRotY[-1][1] - y) < -18: y-=36
-                                                               
-                                                               while (motionMappingRotZ[-1][1] - z) > 18: z+=36
-                                                               while (motionMappingRotZ[-1][1] - z) < -18: z-=36
-                                                       
-                                                       motionMappingRotX.append((currentFrame, x))
-                                                       motionMappingRotY.append((currentFrame, y))
-                                                       motionMappingRotZ.append((currentFrame, z))
-                                               # Done importing motion data #
-                                       
-                                       lineIdx += 1
-                               
-                               #=======================================#
-                               # Now Write the motion to the IPO's     #
-                               #=======================================#
-                               for key, motion_data in objectMotiondataMapping.iteritems():
-                                       
-                                       # Strip the motion data where all the points have the same falue.
-                                       i = len(motion_data) -2
-                                       while i > 0 and len(motion_data) > 2:
-                                               if motion_data[i][1] == motion_data[i-1][1] == motion_data[i+1][1]:
-                                                       motion_data.pop(i)
-                                               i-=1
-                                       # Done stripping.                                               
-                                       
-                                       obname, tx_type = key
-                                       curve = objectCurveMapping[obname, tx_type]
-                                       for point_data in motion_data:
-                                               curve.addBezier( point_data )
-                               # Imported motion to an IPO
-                               
-                               # No point in looking further, when this loop is done
-                               # There is nothine else left to do                      
-                               break
-                               
-                       # Main file loop
-                       lineIdx += 1
-                       
-               print 'bvh import time for %i frames: %.6f' % (currentFrame, Blender.sys.time() - time1)
-               Window.RedrawAll()
-               Window.WaitCursor(0)
-       
-       Blender.Window.FileSelector(loadBVH, "Import BVH")
-       
-       #=============#
-       # TESTING     #
-       #=============#
-       '''
-       #loadBVH('/metavr/mocap/bvh/boxer.bvh')
-       #loadBVH('/metavr/mocap/bvh/dg-306-g.bvh') # Incompleate EOF
-       #loadBVH('/metavr/mocap/bvh/wa8lk.bvh') # duplicate joint names, \r line endings.
-       #loadBVH('/metavr/mocap/bvh/walk4.bvh') # 0 channels
-       scale  = 0.01
-       import os
-       DIR = '/metavr/mocap/bvh/'
-       for f in os.listdir(DIR):
-               if f.endswith('.bvh'):
-                       s = Scene.New(f)
-                       s.makeCurrent()
-                       loadBVH(DIR + f)
-       '''
-if __name__ == '__main__':
-       main()
\ No newline at end of file
+# # PSYCO IS CRASHING ON MY SYSTEM
+# # Attempt to load psyco, speed things up
+# try:
+#   print 'using psyco to speed up BVH importing'
+#   import psyco
+#   psyco.full()
+#  
+# except:
+#   print 'psyco is not present on this system'
+
+# Default scale
+scale = 0.01
+
+# Update as we load?
+debug = 0
+
+# Get the current scene.
+scn = Scene.GetCurrent()
+context = scn.getRenderingContext()
+
+# Here we store the Ipo curves in the order they load.
+channelCurves = []
+
+# Object list
+# We need this so we can loop through the objects and edit there IPO's 
+# Chenging there rotation to EULER rotation
+objectList = []
+
+def getScale():
+       return Draw.PupFloatInput('BVH Scale: ', 0.01, 0.001, 10.0, 0.1, 3)
+
+def MAT(m):
+       if len(m) == 3:
+               return Blender.Mathutils.Matrix(m[0], m[1], m[2])
+       elif len(m) == 4:
+               return Blender.Mathutils.Matrix(m[0], m[1], m[2], m[3])
+
+
+
+#===============================================#
+# eulerRotation: converts X, Y, Z rotation      #
+# to eular Rotation. This entire function       #
+# is copied from Reevan Mckay's BVH script      #
+#===============================================#
+# Vars used in eular rotation funtcion
+DEG_TO_RAD = math.pi/180.0
+RAD_TO_DEG = 180.0/math.pi
+PI=3.14159
+
+def eulerRotate(x,y,z): 
+  #=================================
+  def RVMatMult3 (mat1,mat2):
+  #=================================
+    mat3=[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]]
+    for i in range(3):
+      for k in range(3):
+        for j in range(3):
+          mat3[i][k]=mat3[i][k]+mat1[i][j]*mat2[j][k]
+    return mat3
+  
+  
+  #=================================
+  def  RVAxisAngleToMat3 (rot4):
+  #    Takes a direction vector and
+  #    a rotation (in rads) and
+  #    returns the rotation matrix.
+  #    Graphics Gems I p. 466:
+  #=================================
+    mat3=[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]]
+    if math.fabs(rot4[3])>0.01:
+      s=math.sin(rot4[3])
+      c=math.cos(rot4[3])
+      t=1.0-math.cos(rot4[3])
+    else:
+      s=rot4[3]
+      c=1.0
+      t=0.0
+
+    x=rot4[0]; y=rot4[1]; z=rot4[2]
+    
+    mat3[0][0]=t*x*x+c
+    mat3[0][1]=t*x*y+s*z
+    mat3[0][2]=t*x*z-s*y 
+    
+    mat3[1][0]=t*x*y-s*z
+    mat3[1][1]=t*y*y+c
+    mat3[1][2]=t*y*z+s*x
+    
+    mat3[2][0]=t*x*z+s*y
+    mat3[2][1]=t*y*z-s*x
+    mat3[2][2]=t*z*z+c
+    
+    return mat3
+  eul = [x,y,z]
+  
+  for jj in range(3):
+    while eul[jj] < 0:
+      eul[jj] = eul[jj] + 360.0
+    while eul[jj] >= 360.0:
+      eul[jj] = eul[jj] - 360.0
+
+  eul[0] = eul[0]*DEG_TO_RAD
+  eul[1] = eul[1]*DEG_TO_RAD
+  eul[2] = eul[2]*DEG_TO_RAD
+  
+  xmat=RVAxisAngleToMat3([1,0,0,eul[0]])
+  ymat=RVAxisAngleToMat3([0,1,0,eul[1]])
+  zmat=RVAxisAngleToMat3([0,0,1,eul[2]])
+  
+  mat=[[1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0]]  
+  
+  # Standard BVH multiplication order
+  mat=RVMatMult3 (zmat,mat)
+  mat=RVMatMult3 (xmat,mat)
+  mat=RVMatMult3 (ymat,mat)
+  
+  
+  '''
+  # Screwy Animation Master BVH multiplcation order
+  mat=RVMatMult3 (ymat,mat)
+  mat=RVMatMult3 (xmat,mat)
+  mat=RVMatMult3 (zmat,mat)
+  '''
+  mat = MAT(mat)
+  
+  eul = mat.toEuler()
+  x =- eul[0]/-10
+  y =- eul[1]/-10
+  z =- eul[2]/-10
+  
+  return x, y, z # Returm euler roration values.
+
+
+
+#===============================================#
+# makeJoint: Here we use the node data          #
+# from the BVA file to create an empty          #
+#===============================================#
+def makeJoint(name, parent, prefix, offset, channels):
+  global scale
+  # Make Empty, with the prefix in front of the name
+  ob = Object.New('Empty', prefix + name) # New object, ob is shorter and nicer to use.
+  scn.link(ob) # place the object in the current scene
+  
+  # Offset Empty
+  ob.setLocation(offset[0]*scale, offset[1]*scale, offset[2]*scale)
+
+  # Make me a child of another empty.
+  # Vale of None will make the empty a root node (no parent)
+  if parent[-1] != None:
+    obParent = Object.Get(prefix + parent[-1]) # We use this a bit so refrence it here.
+    obParent.makeParent([ob], 0, 1) #ojbs, noninverse, 1 = not fast.
+
+  # Add Ipo's for necessary channels
+  newIpo = Ipo.New('Object', prefix + name)
+  ob.setIpo(newIpo)
+  for channelType in channels:
+    if channelType == 'Xposition':
+      newIpo.addCurve('LocX')
+      newIpo.getCurve('LocX').setInterpolation('Linear')
+    if channelType == 'Yposition':
+      newIpo.addCurve('LocY')
+      newIpo.getCurve('LocY').setInterpolation('Linear')
+    if channelType == 'Zposition':
+      newIpo.addCurve('LocZ')
+      newIpo.getCurve('LocZ').setInterpolation('Linear')
+
+    if channelType == 'Zrotation':
+      newIpo.addCurve('RotZ')
+      newIpo.getCurve('RotZ').setInterpolation('Linear')
+    if channelType == 'Yrotation':
+      newIpo.addCurve('RotY')
+      newIpo.getCurve('RotY').setInterpolation('Linear')
+    if channelType == 'Xrotation':
+      newIpo.addCurve('RotX')
+      newIpo.getCurve('RotX').setInterpolation('Linear')
+
+  # Add to object list
+  objectList.append(ob)
+  
+  # Redraw if debugging
+  if debug: Blender.Redraw()
+  
+
+#===============================================#
+# makeEnd: Here we make an end node             #
+# This is needed when adding the last bone      #
+#===============================================#
+def makeEnd(parent, prefix, offset):
+  # Make Empty, with the prefix in front of the name, end nodes have no name so call it its parents name+'_end'
+  ob = Object.New('Empty', prefix + parent[-1] + '_end') # New object, ob is shorter and nicer to use.
+  scn.link(ob)
+  
+  # Dont check for a parent, an end node MUST have a parent
+  obParent = Object.Get(prefix + parent[-1]) # We use this a bit so refrence it here.
+  obParent.makeParent([ob], 0, 1) #ojbs, noninverse, 1 = not fast.
+
+  # Offset Empty
+  ob.setLocation(offset[0]*scale, offset[1]*scale, offset[2]*scale) 
+  
+  # Redraw if debugging
+  if debug: Blender.Redraw()  
+  
+
+
+
+#===============================================#
+# MAIN FUNCTION - All things are done from here #
+#===============================================#
+def loadBVH(filename):
+  global scale
+  print ''
+  print 'BVH Importer 1.0 by Campbell Barton (Ideasman) - ideasman@linuxmail.org'
+  alpha='abcdefghijklmnopqrstuvewxyz'
+  ALPHA=alpha+alpha.upper()
+  ALPHA+=' 0123456789+-{}. '  
+  time1 = Blender.sys.time()
+  tmpScale = getScale()
+  if tmpScale != None:
+    scale = tmpScale
+  
+  # File loading stuff
+  # Open the file for importing
+  file = open(filename, 'r')  
+  fileData = file.readlines()
+  # Make a list of lines
+  lines = []
+  for fileLine in fileData:
+    fileLine=fileLine.replace('..','.')
+    newLine = string.split(fileLine)
+    if newLine != []:
+      t=[]
+      for n in newLine:
+         for n0 in n:
+           if n0 not in ALPHA:
+              n=n.replace(n0,'')  
+         t.append(n)
+      lines.append(t)
+
+    
+  del fileData
+  # End file loading code
+
+  # Call object names with this prefix, mainly for scenes with multiple BVH's - Can imagine most partr names are the same
+  # So in future
+  #prefix = str(len(lines)) + '_'
+  
+  prefix = '_'
+  
+  # Create Hirachy as empties
+  if lines[0][0] == 'HIERARCHY':
+    print 'Importing the BVH Hierarchy for:', filename
+  else:
+    return 'ERROR: This is not a BVH file'
+  
+  # A liniar list of ancestors to keep track of a single objects heratage
+  # at any one time, this is appended and removed, dosent store tree- just a liniar list.
+  # ZERO is a place holder that means we are a root node. (no parents)
+  parent = [None]  
+  
+  #channelList [(<objectName>, [channelType1, channelType2...]),  (<objectName>, [channelType1, channelType2...)]
+  channelList = []
+  channelIndex = -1
+
+  
+
+  lineIdx = 1 # An index for the file.
+  while lineIdx < len(lines) -1:
+    #...
+    if lines[lineIdx][0] == 'ROOT' or lines[lineIdx][0] == 'JOINT':
+      if lines[lineIdx][0] == 'JOINT' and len(lines[lineIdx])>2:
+         for j in range(2,len(lines[lineIdx])) :
+             lines[lineIdx][1]+='_'+lines[lineIdx][j]
+
+      # MAY NEED TO SUPPORT MULTIPLE ROOT's HERE!!!, Still unsure weather multiple roots are possible.??
+
+      print len(parent) * '  ' + 'node:',lines[lineIdx][1],' parent:',parent[-1]
+      print lineIdx
+      name = lines[lineIdx][1]
+      print name,lines[lineIdx+1],lines[lineIdx+2]
+      lineIdx += 2 # Incriment to the next line (Offset)
+      offset = ( float(lines[lineIdx][1]), float(lines[lineIdx][2]), float(lines[lineIdx][3]) )
+      lineIdx += 1 # Incriment to the next line (Channels)
+      
+      # newChannel[Xposition, Yposition, Zposition, Xrotation, Yrotation, Zrotation]
+      # newChannel has Indecies to the motiondata,
+      # -1 refers to the last value that will be added on loading at a value of zero
+      # We'll add a zero value onto the end of the MotionDATA so this is always refers to a value.
+      newChannel = [-1, -1, -1, -1, -1, -1] 
+      for channel in lines[lineIdx][2:]:
+        channelIndex += 1 # So the index points to the right channel
+        if channel == 'Xposition':
+          newChannel[0] = channelIndex
+        elif channel == 'Yposition':
+          newChannel[1] = channelIndex
+        elif channel == 'Zposition':
+          newChannel[2] = channelIndex
+        elif channel == 'Xrotation':
+          newChannel[3] = channelIndex
+        elif channel == 'Yrotation':
+          newChannel[4] = channelIndex
+        elif channel == 'Zrotation':
+          newChannel[5] = channelIndex
+      
+      channelList.append(newChannel)
+      
+      channels = lines[lineIdx][2:]
+      
+      # Call funtion that uses the gatrhered data to make an empty.
+      makeJoint(name, parent, prefix, offset, channels)
+      
+      # If we have another child then we can call ourselves a parent, else 
+      parent.append(name)
+
+    # Account for an end node
+    if lines[lineIdx][0] == 'End' and lines[lineIdx][1] == 'Site': # There is somtimes a name afetr 'End Site' but we will ignore it.
+      lineIdx += 2 # Incriment to the next line (Offset)
+      offset = ( float(lines[lineIdx][1]), float(lines[lineIdx][2]), float(lines[lineIdx][3]) )
+      makeEnd(parent, prefix, offset)
+
+      # Just so we can remove the Parents in a uniform way- End end never has kids
+      # so this is a placeholder
+      parent.append(None)
+
+    if lines[lineIdx] == ['}']:
+      parent = parent[:-1] # Remove the last item
+
+
+    #=============================================#
+    # BVH Structure loaded, Now import motion     #
+    #=============================================#    
+    if lines[lineIdx] == ['MOTION']:
+      print '\nImporting motion data'
+      lineIdx += 3 # Set the cursor to the forst frame
+      
+      #=============================================#
+      # Loop through frames, each line a frame      #
+      #=============================================#      
+      currentFrame = 1
+      print 'frames: ',
+      
+      
+      #=============================================#
+      # Add a ZERO keyframe, this keeps the rig     #
+      # so when we export we know where all the     #
+      # joints start from                           #
+      #=============================================#  
+      obIdx = 0
+      while obIdx < len(objectList) -1:
+        if channelList[obIdx][0] != -1:
+          objectList[obIdx].getIpo().getCurve('LocX').addBezier((currentFrame,0))
+        if channelList[obIdx][1] != -1:
+          objectList[obIdx].getIpo().getCurve('LocY').addBezier((currentFrame,0))
+        if channelList[obIdx][2] != -1:
+          objectList[obIdx].getIpo().getCurve('LocZ').addBezier((currentFrame,0))
+        if channelList[obIdx][3] != '-1' or channelList[obIdx][4] != '-1' or channelList[obIdx][5] != '-1':
+          objectList[obIdx].getIpo().getCurve('RotX').addBezier((currentFrame,0))
+          objectList[obIdx].getIpo().getCurve('RotY').addBezier((currentFrame,0))
+          objectList[obIdx].getIpo().getCurve('RotZ').addBezier((currentFrame,0))
+        obIdx += 1
+      
+      while lineIdx < len(lines):
+        
+        # Exit loop if we are past the motiondata.
+        # Some BVH's have extra tags like 'CONSTRAINTS and MOTIONTAGS'
+        # I dont know what they do and I dont care, they'll be ignored here.
+        if len(lines[lineIdx]) < len(objectList):
+          print '...ending on unknown tags'
+          break
+        
+        
+        currentFrame += 1 # Incriment to next frame
+                
+        #=============================================#
+        # Import motion data and assign it to an IPO  #
+        #=============================================#
+        lines[lineIdx].append('0') # Use this as a dummy var for objects that dont have a rotate channel.
+        obIdx = 0
+        if debug: Blender.Redraw() 
+        while obIdx < len(objectList) -1:
+          if channelList[obIdx][0] != -1:
+            VAL0=lines[lineIdx][channelList[obIdx][0]]  
+            if VAL0.find('.')==-1:
+               VAL0=VAL0[:len(VAL0)-6]+'.'+VAL0[-6:] 
+            objectList[obIdx].getIpo().getCurve('LocX').addBezier((currentFrame, scale * float(VAL0)))
+
+          if channelList[obIdx][1] != -1:
+            VAL1=lines[lineIdx][channelList[obIdx][1]]  
+            if VAL1.find('.')==-1:
+               VAL1=VAL1[:len(VAL1)-6]+'.'+VAL1[-6:] 
+            objectList[obIdx].getIpo().getCurve('LocY').addBezier((currentFrame, scale * float(VAL1)))
+
+          if channelList[obIdx][2] != -1:
+            VAL2=lines[lineIdx][channelList[obIdx][2]]  
+            if VAL2.find('.')==-1:
+               VAL2=VAL2[:len(VAL2)-6]+'.'+VAL2[-6:] 
+            objectList[obIdx].getIpo().getCurve('LocZ').addBezier((currentFrame, scale * float(VAL2)))
+          
+          if channelList[obIdx][3] != '-1' or channelList[obIdx][4] != '-1' or channelList[obIdx][5] != '-1':
+            VAL3=lines[lineIdx][channelList[obIdx][3]]  
+            if VAL3.find('.')==-1:
+               VAL3=VAL3[:len(VAL3)-6]+'.'+VAL3[-6:]
+            VAL4=lines[lineIdx][channelList[obIdx][4]]
+            if VAL4.find('.')==-1:
+               VAL4=VAL4[:len(VAL4)-6]+'.'+VAL4[-6:]
+
+            VAL5=lines[lineIdx][channelList[obIdx][5]] 
+            if VAL5.find('.')==-1:
+               VAL5=VAL5[:len(VAL5)-6]+'.'+VAL5[-6:]
+
+            x, y, z = eulerRotate(float(VAL3), float(VAL4), float(VAL5))
+
+            objectList[obIdx].getIpo().getCurve('RotX').addBezier((currentFrame, x))
+            objectList[obIdx].getIpo().getCurve('RotY').addBezier((currentFrame, y))
+            objectList[obIdx].getIpo().getCurve('RotZ').addBezier((currentFrame, z))
+
+          obIdx += 1
+          # Done importing motion data #
+        
+        # lines[lineIdx] = None # Scrap old motion data, save some memory?
+        lineIdx += 1
+      # We have finished now
+      print currentFrame, 'done.'
+     
+      # No point in looking further, when this loop is done
+      # There is nothine else left to do      
+      print 'Imported ', currentFrame, ' frames'
+      break
+      
+    # Main file loop
+    lineIdx += 1
+  print "bvh import time: ", Blender.sys.time() - time1
+
+Blender.Window.FileSelector(loadBVH, "Import BVH")
index c5d2eb5568e24f9934707b450b1f9e4caf9692c9..4ce58e06e10ed387e6d263949507f6d17129d321 100644 (file)
@@ -29,26 +29,6 @@ Usage:<br>
 __author__ = "Campbell Barton AKA Ideasman"
 __url__ = ["http://members.iinet.net.au/~cpbarton/ideasman/", "blender", "elysiun"]
 
-# -------------------------------------------------------------------------- 
-# ***** BEGIN GPL LICENSE BLOCK ***** 
-# 
-# This program 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. 
-# 
-# This program 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 this program; if not, write to the Free Software Foundation, 
-# Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA. 
-# 
-# ***** END GPL LICENCE BLOCK ***** 
-# -------------------------------------------------------------------------- 
-
 import Blender
 from Blender import *
 import sys as python_sys
@@ -152,7 +132,7 @@ def unzip(list):
                                this function will fail
        """
        
-       if not list: return ()
+       if len(list) == 0: return ()
        l = []
        for t in range(len(list[0])):
                l.append(map( lambda x,t=t: x[t], list ))
@@ -233,7 +213,7 @@ def rdir(dirString, depth=0):
                        # Dont bother with this data.
                        continue
                
-               if type(dirItem) != types.StringType:
+               if type(dirItem) != type('str'):
                        print dirItem, type(dirItem)
                
                if dirItem not in COLLECTED_VAR_NAMES.keys():
@@ -249,17 +229,17 @@ def rdir(dirString, depth=0):
                #print type(dirItem)
                #if type(dirData) == types.ClassType or \
                #        type(dirData) == types.ModuleType:
-               type_dirData = type(dirData)
-               if type_dirData != types.StringType and\
-               type_dirData != types.DictType and\
-               type_dirData != types.DictionaryType and\
-               type_dirData != types.FloatType and\
-               type_dirData != types.IntType and\
-               type_dirData != types.NoneType and\
-               type_dirData != types.StringTypes and\
-               type_dirData != types.TypeType and\
-               type_dirData != types.TupleType and\
-               type_dirData != types.BuiltinFunctionType:
+               
+               if type(dirData) != types.StringType and\
+               type(dirData) != types.DictType and\
+               type(dirData) != types.DictionaryType and\
+               type(dirData) != types.FloatType and\
+               type(dirData) != types.IntType and\
+               type(dirData) != types.NoneType and\
+               type(dirData) != types.StringTypes and\
+               type(dirData) != types.TypeType and\
+               type(dirData) != types.TupleType and\
+               type(dirData) != types.BuiltinFunctionType:
                        # print type(dirData), dirItem
                        # Dont loop up dirs for strings ints etc.
                        if dirItem not in dirStringSplit:
@@ -539,17 +519,16 @@ def handle_event(evt, val):
                                menuList.sort()
                                
                                choice = PupMenuLess( # Menu for the user to choose the autocompleate
-                               'Choices (Shift for local name, Ctrl for Docs)%t|' + # Title Text
+                               'Choices (Shift for Whole name, Ctrl for Docs)%t|' + # Title Text
                                '|'.join(['%s,  %s' % m for m in menuList])) # Use Absolute names m[0]
                                
                                if choice != -1:
                                        if Window.GetKeyQualifiers() & Window.Qual.CTRL:  # Help
                                                cmdBuffer[-1].cmd = ('help(%s%s) ' % (cmdBuffer[-1].cmd[:cursor - len(editVar)], menuList[choice-1][0]))    
                                        elif Window.GetKeyQualifiers() & Window.Qual.SHIFT:  # Put in the long name
-                                               cmdBuffer[-1].cmd = ('%s%s%s' % (cmdBuffer[-1].cmd[:cursor - len(editVar)], menuList[choice-1][1], cmdBuffer[-1].cmd[cursor:]))    
-                                       else: # Only paste in the Short name
                                                cmdBuffer[-1].cmd = ('%s%s%s' % (cmdBuffer[-1].cmd[:cursor - len(editVar)], menuList[choice-1][0], cmdBuffer[-1].cmd[cursor:]))    
-                                               
+                                       else: # Only paste in the Short name
+                                               cmdBuffer[-1].cmd = ('%s%s%s' % (cmdBuffer[-1].cmd[:cursor - len(editVar)], menuList[choice-1][1], cmdBuffer[-1].cmd[cursor:]))    
                                                
                else:
                        # print 'NO EDITVAR'
@@ -560,8 +539,11 @@ def handle_event(evt, val):
        # Quit from menu only
        #if (evt == Draw.ESCKEY and not val):
        #       Draw.Exit()
-       if evt == Draw.MOUSEX or evt == Draw.MOUSEY: # AVOID TOO MANY REDRAWS.
-               return  
+       if evt == Draw.MOUSEX: # AVOID TOO MANY REDRAWS.
+               return
+       elif evt == Draw.MOUSEY:
+               return
+       
        
        
        global cursor
@@ -823,4 +805,4 @@ cmdBuffer.append(cmdLine(' ', 0, 0))
 def main():
        Draw.Register(draw_gui, handle_event, handle_button_event)
 
-main()
\ No newline at end of file
+main()
index 8dadbf3c01c7822364e2bf1d269dd482202cacc0..8680890b0ced49a5bd3175b24b8b745d9ee7424c 100644 (file)
@@ -245,8 +245,8 @@ def read_lwo2(file, filename, typ="LWO2"):
     # init value is: object_list = [[None, {}, [], [], {}, {}, 0, {}, {}]]
     #0 - objname                    #original name
     #1 - obj_dict = {TAG}           #objects created
-    #2 - verts = []                 #object vertices
-    #3 - faces = []                 #object faces (associations poly -> vertices)
+    #2 - verts = []                 #object vertexes
+    #3 - faces = []                 #object faces (associations poly -> vertexes)
     #4 - obj_dim_dict = {TAG}       #tuples size and pos in local object coords - used for NON-UV mappings
     #5 - polytag_dict = {TAG}       #tag to polygon mapping
     #6 - patch_flag                 #0 = surf; 1 = patch (subdivision surface) - it was the image list
@@ -286,7 +286,7 @@ def read_lwo2(file, filename, typ="LWO2"):
                 if object_list[object_index][3] != []:
                     object_list.append([object_list[object_index][0],                  #update name
                                         {},                                            #init
-                                        copy.deepcopy(object_list[object_index][2]),   #same vertices
+                                        copy.deepcopy(object_list[object_index][2]),   #same vertexes
                                         [],                                            #no faces
                                         {},                                            #no need to copy - filled at runtime
                                         {},                                            #polygon tagging will follow
@@ -363,7 +363,7 @@ def read_verts(lwochunk):
             Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
         x, y, z = struct.unpack(">fff", data.read(12))
         verts[i] = (x, z, y)
-    tobj.pprint("read %d vertices" % (i+1))
+    tobj.pprint("read %d vertexes" % (i+1))
     return verts
 # enddef read_verts
 
@@ -444,7 +444,7 @@ def read_vx(data):
 # ======================
 def read_vmap(uvcoords_dict, facesuv_dict, faces, maxvertnum, lwochunk):
     if maxvertnum == 0:
-        tobj.pprint ("Found VMAP but no vertices to map!")
+        tobj.pprint ("Found VMAP but no vertexes to map!")
         return uvcoords_dict, facesuv_dict
     data = cStringIO.StringIO(lwochunk.read())
     map_type = data.read(4)
@@ -460,7 +460,7 @@ def read_vmap(uvcoords_dict, facesuv_dict, faces, maxvertnum, lwochunk):
         vertnum, vnum_size = read_vx(data)
         u, v = struct.unpack(">ff", data.read(8))
         if vertnum >= maxvertnum:
-            tobj.pprint ("Hem: more uvmap than vertices? ignoring uv data for vertex %d" % vertnum)
+            tobj.pprint ("Hem: more uvmap than vertexes? ignoring uv data for vertex %d" % vertnum)
         else:
             my_uv_list[vertnum] = (u, v)
         i += 8 + vnum_size
@@ -483,7 +483,7 @@ def read_vmap(uvcoords_dict, facesuv_dict, faces, maxvertnum, lwochunk):
 def read_vmad(uvcoords_dict, facesuv_dict, faces, maxvertnum, lwochunk):
     maxfacenum = len(faces)
     if maxvertnum == 0 or maxfacenum == 0:
-        tobj.pprint ("Found VMAD but no vertices to map!")
+        tobj.pprint ("Found VMAD but no vertexes to map!")
         return uvcoords_dict, facesuv_dict
     data = cStringIO.StringIO(lwochunk.read())
     map_type = data.read(4)
@@ -508,19 +508,19 @@ def read_vmad(uvcoords_dict, facesuv_dict, faces, maxvertnum, lwochunk):
         i += vnum_size
         u, v = struct.unpack(">ff", data.read(8))
         if polynum >= maxfacenum or vertnum >= maxvertnum:
-            tobj.pprint ("Hem: more uvmap than vertices? ignorig uv data for vertex %d" % vertnum)
+            tobj.pprint ("Hem: more uvmap than vertexes? ignorig uv data for vertex %d" % vertnum)
         else:
             my_uv_list.append( (u,v) )
             newindex = len(my_uv_list) - 1
             for vi in range(len(my_facesuv_list[polynum])): #polynum starting from 1 or from 0?
                 if my_facesuv_list[polynum][vi] == vertnum:
                     my_facesuv_list[polynum][vi] = newindex
-            #end loop on current face vertices
+            #end loop on current face vertexes
         i += 8
     #end loop on uv pairs
     uvcoords_dict[name] = my_uv_list
     facesuv_dict[name] = my_facesuv_list
-    tobj.pprint ("updated %d vertices data" % (newindex-lastindex))
+    tobj.pprint ("updated %d vertexes data" % (newindex-lastindex))
     return uvcoords_dict, facesuv_dict
 
 
@@ -916,7 +916,7 @@ def dist_vector (head, tail): #vector from head to tail
 # ================
 def find_ear(normal, list_dict, verts, face):
     nv = len(list_dict['MF'])
-    #looping through vertices trying to find an ear
+    #looping through vertexes trying to find an ear
     #most likely in case of panic
     mlc = 0
     mla = 1
@@ -974,10 +974,10 @@ def find_ear(normal, list_dict, verts, face):
                         concave_inside = 1
                         break
                 #endif found a concave vertex
-            #end loop looking for concave vertices
+            #end loop looking for concave vertexes
             if (concave == 0) or (concave_inside == 0):
-                #no concave vertices in polygon (should not be): return immediately
-                #looped all concave vertices and no one inside found
+                #no concave vertexes in polygon (should not be): return immediately
+                #looped all concave vertexes and no one inside found
                 return [c, a, b]
         #no convex vertex, try another one
     #end loop to find a suitable base vertex for ear
@@ -1003,12 +1003,12 @@ def reduce_face(verts, face):
     list_dict['P'] = [None] * nv
     #list of distances
     for mvi in list_dict['MF']:
-        #vector between two vertices
+        #vector between two vertexes
         mvi_hiend = (mvi+1) % nv      #last-to-first
         vi_hiend = face[mvi_hiend] #vertex
         vi = face[mvi]
         list_dict['D'][mvi] = dist_vector(verts[vi_hiend], verts[vi])
-    #list of cross products - normals evaluated into vertices
+    #list of cross products - normals evaluated into vertexes
     for vi in range(nv):
         list_dict['X'][vi] = Blender.Mathutils.CrossVecs(list_dict['D'][vi], list_dict['D'][vi-1])
     my_face_normal = Blender.Mathutils.Vector([list_dict['X'][0][0], list_dict['X'][0][1], list_dict['X'][0][2]])
@@ -1050,8 +1050,8 @@ def reduce_face(verts, face):
             list_dict['P'].pop(ct[1])
             one_concave = reduce(lambda x, y: (x) or (y<0.0), list_dict['P'], 0)
             nv -=1
-        else: #here if no more concave vertices
-            if nv == 4: break  #quads only if no concave vertices
+        else: #here if no more concave vertexes
+            if nv == 4: break  #quads only if no concave vertexes
             decomposition_list.append([list_dict['MF'][0], list_dict['MF'][1], list_dict['MF'][2]])
             #physical removal
             list_dict['MF'].pop(1)
@@ -1152,7 +1152,7 @@ def my_create_mesh(complete_vertlist, complete_facelist, current_facelist, objna
 
     mesh = Blender.NMesh.GetRaw()
 
-    #append vertices
+    #append vertexes
     jj = 0
     for i in range(len(complete_vertlist)):
         if vertex_map[i] == 1:
@@ -1161,7 +1161,7 @@ def my_create_mesh(complete_vertlist, complete_facelist, current_facelist, objna
             mesh.verts.append(Blender.NMesh.Vert(x, y, z))
             vertex_map[i] = jj
             jj += 1
-    #end sweep over vertices
+    #end sweep over vertexes
 
     #append faces
     for i in range(len(cur_ptag_faces)):
@@ -1172,7 +1172,7 @@ def my_create_mesh(complete_vertlist, complete_facelist, current_facelist, objna
         #for vi in cur_ptag_faces[i]:
             index = vertex_map[vi]
             face.v.append(mesh.verts[index])
-        #end sweep over vertices
+        #end sweep over vertexes
         mesh.faces.append(face)
     #end sweep over faces
 
index bf02c323f61d90ca97352bffd6f4b83746adb0a0..78d173d88fb0363c445df8b0762d0fee7193460e 100644 (file)
@@ -9,7 +9,7 @@ Tooltip: 'Export the UV face layout of the selected object to a .TGA file'
 
 __author__ = "Martin 'theeth' Poirier"
 __url__ = ("http://www.blender.org", "http://www.elysiun.com")
-__version__ = "1.4"
+__version__ = "1.3a"
 
 __bpydoc__ = """\
 This script exports the UV face layout of the selected mesh object to
@@ -26,9 +26,8 @@ There are more options to configure, like setting export path, if image should
 use object's name and more.
 
 Notes:<br>
-        Jean-Michel Soler (jms) wrote TGA functions used by this script.<br>
-        Zaz added the default path code and Selected Face option.<br>
-        Macouno fixed a rounding error in the step calculations<br>
+    Jean-Michel Soler (jms) wrote TGA functions used by this script.
+    Zaz added the default path code and Selected Face option.
 """
 
 
@@ -63,22 +62,19 @@ Notes:<br>
 # Communicate problems and errors on:
 # http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender 
 # --------------------------
-#       Version 1.1            
+#    Version 1.1      
 # Clear a bug that crashed the script when UV coords overlapped in the same faces
 # --------------------------
-#       Version 1.2
+#    Version 1.2
 # Now with option to use the object's name as filename
 # --------------------------
-#       Version 1.3 Updates by Zaz from Elysiun.com
+#    Version 1.3 Updates by Zaz from Elysiun.com
 # Default path is now the directory of the last saved .blend
 # New options: Work on selected face only & Scale image when face wraps
 # --------------------------
-#       Version 1.3a
+#    Version 1.3a
 # Corrected a minor typo and added the tga extension to both export call
 # --------------------------
-#       Version 1.4 Updates by Macouno from Elysiun.com
-# Fixed rounding error that can cause breaks in lines.
-# --------------------------
 
 import Blender
 from math import *
@@ -138,42 +134,42 @@ def bevent(evt):
                        UV_Export(bSize.val, bWSize.val, bFile.val + ".tga")
 
 def Buffer(height=16, width=16, profondeur=3,rvb=255 ):  
-       """  
-       reserve l'espace memoire necessaire  
-       """  
-       p=[rvb]  
-       b=p*height*width*profondeur  
-       return b  
+   """  
+   reserve l'espace memoire necessaire  
+   """  
+   p=[rvb]  
+   b=p*height*width*profondeur  
+   return b  
 
 def write_tgafile(loc2,bitmap,width,height,profondeur):  
-       f=open(loc2,'wb')  
+   f=open(loc2,'wb')  
 
-       Origine_en_haut_a_gauche=32  
-       Origine_en_bas_a_gauche=0  
+   Origine_en_haut_a_gauche=32  
+   Origine_en_bas_a_gauche=0  
 
-       Data_Type_2=2  
-       RVB=profondeur*8  
-       RVBA=32  
-       entete0=[]  
-       for t in range(18):  
-         entete0.append(chr(0))  
+   Data_Type_2=2  
+   RVB=profondeur*8  
+   RVBA=32  
+   entete0=[]  
+   for t in range(18):  
+     entete0.append(chr(0))  
 
-       entete0[2]=chr(Data_Type_2)  
-       entete0[13]=chr(width/256)  
-       entete0[12]=chr(width % 256)  
-       entete0[15]=chr(height/256)  
-       entete0[14]=chr(height % 256)  
-       entete0[16]=chr(RVB)  
-       entete0[17]=chr(Origine_en_bas_a_gauche)  
+   entete0[2]=chr(Data_Type_2)  
+   entete0[13]=chr(width/256)  
+   entete0[12]=chr(width % 256)  
+   entete0[15]=chr(height/256)  
+   entete0[14]=chr(height % 256)  
+   entete0[16]=chr(RVB)  
+   entete0[17]=chr(Origine_en_bas_a_gauche)  
 
-       #Origine_en_haut_a_gauche  
+   #Origine_en_haut_a_gauche  
 
-       for t in entete0:  
-         f.write(t)  
+   for t in entete0:  
+     f.write(t)  
 
-       for t in bitmap:  
-         f.write(chr(t))  
-       f.close()  
+   for t in bitmap:  
+     f.write(chr(t))  
+   f.close()  
 
 def UV_Export(size, wsize, file):
        obj = Blender.Object.GetSelected()
@@ -242,12 +238,11 @@ def UV_Export(size, wsize, file):
                                co2 = f[index + 1]
                        else:
                                co2 = f[0]
-
-                       step = int(ceil(size*sqrt((co1[0]-co2[0])**2+(co1[1]-co2[1])**2)))
+                       step = int(size*sqrt((co1[0]-co2[0])**2+(co1[1]-co2[1])**2))
                        if step:
-                               for t in range(step):
-                                       x = int(floor((co1[0] + t*(co2[0]-co1[0])/step) * size))
-                                       y = int(floor((co1[1] + t*(co2[1]-co1[1])/step) * size))
+                               for t in range(step + 1):
+                                       x = int((co1[0] + t*(co2[0]-co1[0])/step) * size)
+                                       y = int((co1[1] + t*(co2[1]-co1[1])/step) * size)
 
                                        if bWrap.val:
                                                x = x % wrapSize
@@ -256,17 +251,16 @@ def UV_Export(size, wsize, file):
                                                x = int ((x - minx) * scale)
                                                y = int ((y - miny) * scale)
                                                
-                                       co = x * 3 + y * 3 * size;
-                                       
+                                       co = x * 3 + y * 3 * size
                                        img[co] = 0
                                        img[co+1] = 0
-                                       img[co+2] = 0
+                                       img[co+2] = 255
                                        if wsize > 1:
                                                for x in range(-1*wsize + 1,wsize):
                                                        for y in range(-1*wsize,wsize):
                                                                img[co + 3 * x + y * 3 * size] = 0
                                                                img[co + 3 * x + y * 3 * size +1] = 0
-                                                               img[co + 3 * x + y * 3 * size +2] = 0
+                                                               img[co + 3 * x + y * 3 * size +2] = 255
        
                for v in f:
                        x = int(v[0] * size)
@@ -282,7 +276,8 @@ def UV_Export(size, wsize, file):
                        co = x * 3 + y * 3 * size
                        img[co] = 0
                        img[co+1] = 0
-                       img[co+2] = 255                                 
+                       img[co+2] = 0
+                               
        
        
        write_tgafile(file,img,size,size,3)
index 16e8b5652aa0374e55e1563be9974e4623daa854..e4cd8e39acad62a79771c917e5bc85e195ce9fbc 100644 (file)
@@ -43,9 +43,6 @@ void free_path(struct Path *path);
 void calc_curvepath(struct Object *ob);
 int interval_test(int min, int max, int p1, int cycl);
 int where_on_path(struct Object *ob, float ctime, float *vec, float *dir);
-void frames_duplilist(struct Object *ob);
-void vertex_duplilist(struct Scene *sce, struct Object *par);
-void particle_duplilist(struct Scene *sce, struct Object *par, struct PartEff *paf);
 void free_duplilist(void);
 void make_duplilist(struct Scene *sce, struct Object *ob);
 int count_duplilist(struct Object *ob);
index 905b6d3bf74c9f5840349744741eaaf8dd47a035..8a86e88406f4fbddf66b799d755470fc0b89df62 100644 (file)
@@ -88,6 +88,7 @@ float WardIso_Spec(float *n, float *l, float *v, float a, int);
 float Toon_Diff(float *n, float *l, float *v, float a, float b);
 float OrenNayar_Diff(float *n, float *l, float *v, float rough);
 float Minnaert_Diff(float nl, float *n, float *v, float a);
+float Fresnel_Diff(float *vn, float *lv, float *view, float ior, float fac);
 
 void add_to_diffuse(float *, ShadeInput *, float, float, float, float);
 void ramp_diffuse_result(float *diff, ShadeInput *shi);
@@ -158,7 +159,6 @@ void do_material_tex(ShadeInput *shi);
 void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, 
        float *tg, float *tb, float *ta);
 void init_render_textures(void);
-void end_render_textures(void);
 
 void RE_free_envmap(struct EnvMap *env);      
 void RE_free_envmapdata(struct EnvMap *env);
index c68d4b8b10e57f33c61945ac3f1398ffc7f1abb1..d149d2b6e7cff40f2342b8bf2c7e40c3ffed96cd 100644 (file)
@@ -38,10 +38,8 @@ struct Effect;
 struct ListBase;
 struct Object;
 struct PartEff;
-struct MTex;
-struct Mesh;
-struct WaveEff;
 struct Particle;
+struct Group;
 
 struct Effect *add_effect(int type);
 void free_effect(struct Effect *eff);
@@ -57,7 +55,7 @@ void build_particle_system(struct Object *ob);
 /* particle deflector */
 #define PE_WIND_AS_SPEED 0x00000001
 
-struct ListBase *pdInitEffectors(struct Object *ob);
+struct ListBase *pdInitEffectors(struct Object *obsrc, struct Group *group);
 void                   pdEndEffectors(struct ListBase *lb);
 void                   pdDoEffectors(struct ListBase *lb, float *opco, float *force, float *speed, float cur_time, float loc_time, unsigned int flags);
 
index 265d16579c22c136e17d613184d82d4b448aed7a..4e69f18a2387ade98c1db80f83e9aaab37d264a5 100644 (file)
 #define BKE_GROUP_H
 
 struct Group;
-struct GroupKey;
 struct GroupObject;
-struct ObjectKey;
 struct Object;
 
-void free_object_key(struct ObjectKey *ok);
 void free_group_object(struct GroupObject *go);
 void free_group(struct Group *group);
 struct Group *add_group(void);
-void object_to_obkey(struct Object *ob, struct ObjectKey *ok);
-void obkey_to_object(struct ObjectKey *ok, struct Object *ob);
-void add_object_key(struct GroupObject *go, struct GroupKey *gk);
 void add_to_group(struct Group *group, struct Object *ob);
 void rem_from_group(struct Group *group, struct Object *ob);
-void add_group_key(struct Group *group);
-void set_object_key(struct Object *ob, struct ObjectKey *ok);
-void set_group_key(struct Group *group);
 struct Group *find_group(struct Object *ob);
-void set_group_key_name(struct Group *group, char *name);
-void set_group_key_frame(struct Group *group, float frame);
+int object_in_group(struct Object *ob, struct Group *group);
 
 #endif
 
index fcdbed10ffa6b83b287066044cfaee2b95fcc981..16a320010eca9b76d603de62c7bd6a1fd71d0e53 100644 (file)
@@ -48,16 +48,18 @@ void init_material(struct Material *ma);
 struct Material *add_material(char *name);
 struct Material *copy_material(struct Material *ma);
 void make_local_material(struct Material *ma);
+
 struct Material ***give_matarar(struct Object *ob);
 short *give_totcolp(struct Object *ob);
 struct Material *give_current_material(struct Object *ob, int act);
 ID *material_from(struct Object *ob, int act);
 void assign_material(struct Object *ob, struct Material *ma, int act);
 void new_material_to_objectdata(struct Object *ob);
+
+struct Material *get_active_matlayer(struct Material *ma);
 void init_render_material(struct Material *ma);
 void init_render_materials(void);
-void end_render_material(struct Material *ma);
-void end_render_materials(void);
+
 void automatname(struct Material *ma);
 void delete_material_index(void);            
 
index 1313ad251e72ea3f61b6f71106e46d15758dc4e6..a7eea6f6393eb8ba04e522861c9ff468bc06a536 100644 (file)
@@ -60,7 +60,7 @@ void free_qtcodecdata(struct QuicktimeCodecData *acd);
 
 void free_scene(struct Scene *me);
 struct Scene *add_scene(char *name);
-int object_in_scene(struct Object *ob, struct Scene *sce);
+struct Base *object_in_scene(struct Object *ob, struct Scene *sce);
 
 void set_scene_bg(struct Scene *sce);
 void set_scene_name(char *name);
index a18a43fb7b8e6458b6bed188dd41cfaef9027579..f0b05802e97e22c51d6d47862076ee7fe2d4093c 100644 (file)
 #define ELEM7(a, b, c, d, e, f, g, h)   ( ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) )
 #define ELEM8(a, b, c, d, e, f, g, h, i)        ( ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) )
 
-/* pointer magic, only to be used for the max 16 Gig mem period */
-/* note that  int is signed! */
-#define POINTER_TO_INT(poin)   (int)( ((long)(poin))>>3 )
-#define INT_TO_POINTER(int)            (void *)( ((long)(int))<<3 )
-
 /* string compare */
 #define STREQ(str, a)           ( strcmp((str), (a))==0 )
 #define STREQ2(str, a, b)       ( STREQ(str, a) || STREQ(str, b) )
index 457c6a2d7e58a0b43ee0d054dd6112a60abf8122..44997480779d7a1b5117d4b09a0f427742599047 100644 (file)
@@ -116,6 +116,7 @@ float WardIso_Spec(float *n, float *l, float *v, float a, int tangent){return 0;
 float Toon_Diff(float *n, float *l, float *v, float a, float b){return 0;}
 float OrenNayar_Diff(float *n, float *l, float *v, float rough){return 0;}
 float Minnaert_Diff(float nl, float *n, float *v, float a){return 0;}
+float Fresnel_Diff(float *vn, float *lv, float *view, float ior, float fac){return 0;}
 
 void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, float g, float b){}
 void ramp_diffuse_result(float *diff, ShadeInput *shi){}
@@ -206,12 +207,11 @@ int BPY_call_importloader(char *name)
 
 void do_material_tex(ShadeInput *shi){}
 void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta){}
-void init_render_textures(void){}
-void end_render_textures(void){}
 
 void    RE_free_envmap(struct EnvMap *env){}      
 struct EnvMap *RE_copy_envmap(struct EnvMap *env){ return env;}
 void    RE_free_envmapdata(struct EnvMap *env){}
+void init_render_textures(void){}
 
 int     RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt){
    return 0;
index b8178dd98cd07b45945106ed6d81e2025a7887b9..b448816589f2a5346ce91fb68a92ff4f662f8aef 100644 (file)
 #include "BLI_arithb.h"
 #include "DNA_listBase.h"
 
-#include "DNA_object_types.h"
 #include "DNA_curve_types.h"
-#include "DNA_key_types.h"
-#include "DNA_view3d_types.h"
 #include "DNA_effect_types.h"
+#include "DNA_group_types.h"
+#include "DNA_key_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_global.h"
@@ -271,7 +272,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir)  /* returns OK
        return 1;
 }
 
-static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par)
+static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par, int clearpar)
 {
        Object *newob;
        
@@ -284,7 +285,7 @@ static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par)
        /* only basis-ball gets displist */
        if(newob->type==OB_MBALL) newob->disp.first= newob->disp.last= NULL;
 
-       if(ob!=par) {   // dupliverts, particle
+       if(clearpar) {  // dupliverts, particle
                newob->parent= NULL;
                newob->track= NULL;
        }       
@@ -293,7 +294,22 @@ static Object *new_dupli_object(ListBase *lb, Object *ob, Object *par)
        return newob;
 }
 
-void frames_duplilist(Object *ob)
+static void group_duplilist(Object *ob)
+{
+       Object *newob;
+       GroupObject *go;
+       float mat[4][4];
+       
+       if(ob->dup_group==NULL) return;
+       
+       for(go= ob->dup_group->gobject.first; go; go= go->next) {
+               newob= new_dupli_object(&duplilist, go->ob, ob, 0);
+               Mat4CpyMat4(mat, newob->obmat);
+               Mat4MulMat4(newob->obmat, mat, ob->obmat);
+       }
+}
+
+static void frames_duplilist(Object *ob)
 {
        extern int enable_cu_speed;     /* object.c */
        Object *newob, copyob;
@@ -315,7 +331,7 @@ void frames_duplilist(Object *ob)
                        else ok= 0;
                }
                if(ok) {
-                       newob= new_dupli_object(&duplilist, ob, ob);
+                       newob= new_dupli_object(&duplilist, ob, ob, 0);
 
                        do_ob_ipo(newob);
                        where_is_object_time(newob, (float)G.scene->r.cfra);
@@ -343,7 +359,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
        VecSubf(vec, vec, vdd->pmat[3]);
        VecAddf(vec, vec, vdd->ob->obmat[3]);
        
-       newob= new_dupli_object(&duplilist, vdd->ob, vdd->par);
+       newob= new_dupli_object(&duplilist, vdd->ob, vdd->par, 1);
        VECCOPY(newob->obmat[3], vec);
        
        if(vdd->par->transflag & OB_DUPLIROT) {
@@ -359,7 +375,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
        
 }
 
-void vertex_duplilist(Scene *sce, Object *par)
+static void vertex_duplilist(Scene *sce, Object *par)
 {
        Object *ob;
        Base *base;
@@ -420,8 +436,7 @@ void vertex_duplilist(Scene *sce, Object *par)
                dm->release(dm);
 }
 
-
-void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
+static void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
 {
        Object *ob, *newob;
        Base *base;
@@ -462,7 +477,7 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
                                                        mtime= pa->time+pa->lifetime;
                                                        
                                                        for(ctime= pa->time; ctime<mtime; ctime+=paf->staticstep) {
-                                                               newob= new_dupli_object(&duplilist, ob, par);
+                                                               newob= new_dupli_object(&duplilist, ob, par, 1);
                                                                
                                                                /* make sure hair grows until the end.. */ 
                                                                if(ctime>pa->time+pa->lifetime) ctime= pa->time+pa->lifetime;
@@ -494,7 +509,7 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
                                                        if((paf->flag & PAF_DIED)==0 && ctime > pa->time+pa->lifetime) continue;
 
                                                        //if(ctime < pa->time+pa->lifetime) {
-                                                       newob= new_dupli_object(&duplilist, ob, par);
+                                                       newob= new_dupli_object(&duplilist, ob, par, 1);
 
                                                        /* to give ipos in object correct offset */
                                                        where_is_object_time(newob, ctime-pa->time);
@@ -523,7 +538,6 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf)
        }
 }
 
-
 void free_duplilist()
 {
        Object *ob;
@@ -551,7 +565,10 @@ void make_duplilist(Scene *sce, Object *ob)
                                font_duplilist(ob);
                        }
                }
-               else if(ob->transflag & OB_DUPLIFRAMES) frames_duplilist(ob);
+               else if(ob->transflag & OB_DUPLIFRAMES) 
+                       frames_duplilist(ob);
+               else if(ob->transflag & OB_DUPLIGROUP)
+                       group_duplilist(ob);
        }
 }
 
index 9273bd8eb712a43ce01b115fa4904003db85d8b2..f7cf3d6d9310796d1e950a02d1d3fef700593800 100644 (file)
@@ -537,6 +537,7 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                        if(ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(nor, lv, shi.view, ma->roughness);
                        else if(ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]);
                        else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(is, nor, shi.view, ma->darkness);
+                       else if(ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]);
                }
                
                back= 0;
@@ -726,15 +727,6 @@ static void init_fastshade_for_ob(Object *ob, int *need_orco_r, float mat[4][4],
                }
        }
 }
-static void end_fastshade_for_ob(Object *ob)
-{
-       int a;
-
-       for(a=0; a<ob->totcol; a++) {
-               Material *ma= give_current_material(ob, a+1);
-               if(ma) end_render_material(ma);
-       }
-}
 
 void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
 {
@@ -846,7 +838,6 @@ void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r
 
        if (dmNeedsFree) dm->release(dm);
 
-       end_fastshade_for_ob(ob);
 }
 
 void shadeDispList(Object *ob)
@@ -986,8 +977,6 @@ void shadeDispList(Object *ob)
                        dl= dl->next;
                }
        }
-       
-       end_fastshade_for_ob(ob);
 }
 
 void reshadeall_displist(void)
@@ -1999,8 +1988,6 @@ void imagestodisplist(void)
                base= base->next;
        }
        
-       end_render_textures();
-       
        allqueue(REDRAWVIEW3D, 0);
 }
 
index acff6d80024622a20bd3c5fa08f634ad5437093a..17dbae4c0af2904f1e3bfaed1022e9cf4c6814df 100644 (file)
 #include <stdlib.h>
 
 #include "MEM_guardedalloc.h"
-#include "DNA_listBase.h"
+
+#include "DNA_curve_types.h"
 #include "DNA_effect_types.h"
-#include "DNA_object_types.h"
-#include "DNA_object_force.h"
+#include "DNA_group_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_listBase.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_material_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_key_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_ipo_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
@@ -326,42 +328,57 @@ typedef struct pEffectorCache {
        Object obcopy;  /* for restoring transformation data */
 } pEffectorCache;
 
+static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc)
+{
+       pEffectorCache *ec;
+       PartDeflect *pd= ob->pd;
+                       
+       if(pd->forcefield == PFIELD_GUIDE) {
+               if(ob->type==OB_CURVE && obsrc->type==OB_MESH) {        /* guides only do mesh particles */
+                       Curve *cu= ob->data;
+                       if(cu->flag & CU_PATH) {
+                               if(cu->path==NULL || cu->path->data==NULL)
+                                       makeDispListCurveTypes(ob, 0);
+                               if(cu->path && cu->path->data) {
+                                       ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
+                                       ec->ob= ob;
+                                       BLI_addtail(lb, ec);
+                               }
+                       }
+               }
+       }
+       else if(pd->forcefield) {
+               ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
+               ec->ob= ob;
+               BLI_addtail(lb, ec);
+       }
+}
 
 /* returns ListBase handle with objects taking part in the effecting */
-ListBase *pdInitEffectors(Object *obsrc)
+ListBase *pdInitEffectors(Object *obsrc, Group *group)
 {
        static ListBase listb={NULL, NULL};
        pEffectorCache *ec;
-       unsigned int layer= obsrc->lay;
        Base *base;
-
-       for(base = G.scene->base.first; base; base= base->next) {
-               if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
-                       Object *ob= base->object;
-                       PartDeflect *pd= ob->pd;
-                       
-                       if(pd->forcefield == PFIELD_GUIDE) {
-                               if(ob->type==OB_CURVE && obsrc->type==OB_MESH) {        /* guides only do mesh particles */
-                                       Curve *cu= ob->data;
-                                       if(cu->flag & CU_PATH) {
-                                               if(cu->path==NULL || cu->path->data==NULL)
-                                                       makeDispListCurveTypes(ob, 0);
-                                               if(cu->path && cu->path->data) {
-                                                       ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
-                                                       ec->ob= ob;
-                                                       BLI_addtail(&listb, ec);
-                                               }
-                                       }
-                               }
+       unsigned int layer= obsrc->lay;
+       
+       if(group) {
+               GroupObject *go;
+               
+               for(go= group->gobject.first; go; go= go->next) {
+                       if( (go->ob->lay & layer) && go->ob->pd && go->ob!=obsrc) {
+                               add_to_effectorcache(&listb, go->ob, obsrc);
                        }
-                       else if(pd->forcefield) {
-                               ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
-                               ec->ob= ob;
-                               BLI_addtail(&listb, ec);
+               }
+       }
+       else {
+               for(base = G.scene->base.first; base; base= base->next) {
+                       if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
+                               add_to_effectorcache(&listb, base->object, obsrc);
                        }
                }
        }
-
+       
        /* make a full copy */
        for(ec= listb.first; ec; ec= ec->next) {
                ec->obcopy= *(ec->ob);
@@ -1663,7 +1680,7 @@ void build_particle_system(Object *ob)
        }
        
        /* get the effectors */
-       effectorbase= pdInitEffectors(ob);
+       effectorbase= pdInitEffectors(ob, paf->group);
        
        /* init geometry, return is 6 x float * me->totvert in size */
        vertexcosnos= (VeNoCo *)mesh_get_mapped_verts_nors(ob);
index 65c4ed42e0312b58097d2e1f6574054f7e8a549d..7405f16d9c0611cf03fe9295d2e0514150d13ced 100644 (file)
@@ -1,19 +1,12 @@
-/*  group.c   sept 2000
- *  - cleaned up mar-01 nzc 
- * 
- * 
- *  ton roosendaal
+/* 
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,7 +24,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 #include <stdio.h>
 #include <config.h>
 #endif
 
-void free_object_key(ObjectKey *ok)
-{
-       if(ok->ipo) ok->ipo->id.us--;
-       
-       MEM_freeN(ok);
-}
-
 void free_group_object(GroupObject *go)
 {
-       ObjectKey *ok;
-       
-       while(go->okey.first) {
-               ok= go->okey.first;
-               BLI_remlink(&go->okey, ok);
-               free_object_key(ok);
-       }
        MEM_freeN(go);
 }
 
@@ -82,14 +61,11 @@ void free_group(Group *group)
        /* don't free group itself */
        GroupObject *go;
        
-       BLI_freelistN(&group->gkey);
-       
        while(group->gobject.first) {
                go= group->gobject.first;
                BLI_remlink(&group->gobject, go);
                free_group_object(go);
        }
-       
 }
 
 Group *add_group()
@@ -100,97 +76,16 @@ Group *add_group()
        return group;
 }
 
-/* assumes 'ok' is unitialized */
-void object_to_obkey(Object *ob, ObjectKey *ok)
-{
-       ok->partype= ob->partype;
-       ok->par1= ob->par1;
-       ok->par2= ob->par2;
-       ok->par3= ob->par3;
-       
-       ok->parent= ob->parent;
-       ok->track= ob->track;
-       
-       ok->ipo= copy_ipo(ob->ipo);
-       
-       memcpy(ok->loc, ob->loc, 7*3*sizeof(float));
-       memcpy(ok->quat, ob->quat, 2*4*sizeof(float));
-       memcpy(ok->obmat, ob->obmat, 3*4*4*sizeof(float));
-       
-       ok->lay= ob->lay;
-       ok->transflag= ob->transflag;
-       ok->trackflag= ob->transflag;
-       ok->upflag= ob->upflag;
-       ok->sf= ob->sf;
-       ok->ctime= ob->ctime;
-
-       
-}
-
-void obkey_to_object(ObjectKey *ok, Object *ob)
-{
-       ob->partype= ok->partype;
-       ob->par1= ok->par1;
-       ob->par2= ok->par2;
-       ob->par3= ok->par3;
-       
-       ob->parent= ok->parent;
-       ob->track= ok->track;
-       
-       /* pretty tricky, this makes ob->ipo blocks with users 'hanging around' */
-       if(ob->ipo) {
-               free_libblock_us(&G.main->ipo, ob->ipo);
-       }
-       ob->ipo= copy_ipo(ok->ipo);
-       
-       memcpy(ob->loc, ok->loc, 7*3*sizeof(float));
-       memcpy(ob->quat, ok->quat, 2*4*sizeof(float));
-       memcpy(ob->obmat, ok->obmat, 3*4*4*sizeof(float));
-       
-       ob->lay= ok->lay;
-       ob->transflag= ok->transflag;
-       ob->trackflag= ok->transflag;
-       ob->upflag= ok->upflag;
-       ob->sf= ok->sf;
-       ob->ctime= ok->ctime;
-}
-
-/* current ob position */
-void add_object_key(GroupObject *go, GroupKey *gk)
-{
-       ObjectKey *ok;
-       
-       /* check if there already is a key */
-       ok= go->okey.first;
-       while(ok) {
-               if(ok->gkey == gk) break;
-               ok= ok->next;
-       }
-       
-       if(ok) {
-               BLI_remlink(&go->okey, ok);
-               free_object_key(ok);
-       }
-       ok= MEM_mallocN(sizeof(ObjectKey), "objectkey");
-       ok->gkey= gk;
-       
-       object_to_obkey(go->ob, ok);
-       
-       BLI_addtail(&go->okey, ok);
-       
-}
-
 /* external */
 void add_to_group(Group *group, Object *ob)
 {
        GroupObject *go;
-       GroupKey *gk;
+       
+       if(group==NULL || ob==NULL) return;
        
        /* check if the object has been added already */
-       go= group->gobject.first;
-       while(go) {
+       for(go= group->gobject.first; go; go= go->next) {
                if(go->ob==ob) return;
-               go= go->next;
        }
        
        go= MEM_callocN(sizeof(GroupObject), "groupobject");
@@ -198,18 +93,13 @@ void add_to_group(Group *group, Object *ob)
        
        go->ob= ob;
        
-       /* keys? */
-       gk= group->gkey.first;
-       while(gk) {
-               add_object_key(go, gk);
-               gk= gk->next;
-       }
 }
 
 void rem_from_group(Group *group, Object *ob)
 {
        GroupObject *go, *gon;
-       ObjectKey *ok;
+       
+       if(group==NULL || ob==NULL) return;
        
        go= group->gobject.first;
        while(go) {
@@ -218,116 +108,31 @@ void rem_from_group(Group *group, Object *ob)
                        BLI_remlink(&group->gobject, go);
                        free_group_object(go);
                }
-               else {
-                       ok= go->okey.first;
-                       while(ok) {
-                               if(ok->parent==ob) ok->parent= NULL;
-                               if(ok->track==ob) ok->track= NULL;
-                               ok= ok->next;
-                       }
-               }
                go= gon;
        }
 }
 
-void add_group_key(Group *group)
+int object_in_group(Object *ob, Group *group)
 {
        GroupObject *go;
-       GroupKey *gk;   
-       int nr=10;
-       extern char colname_array[][20]; /* material.c */
-
-       gk= group->gkey.first;
-       while(gk) {
-               nr++;
-               gk= gk->next;
-       }
-
-       gk= MEM_callocN(sizeof(GroupKey), "groupkey");
-       BLI_addtail(&group->gkey, gk);
-       strcpy(gk->name, colname_array[ nr % 120 ]);
-       
-       go= group->gobject.first;
-       while(go) {
-               add_object_key(go, gk);
-               go= go->next;
-       }
-       
-       group->active= gk;
-}
-
-void set_object_key(Object *ob, ObjectKey *ok)
-{
-       obkey_to_object(ok, ob);        
-}
-
-void set_group_key(Group *group)
-{
-       /* sets active */
-       GroupObject *go;
-       ObjectKey *ok;
        
-       if(group->active==NULL) return;
+       if(group==NULL || ob==NULL) return 0;
        
-       go= group->gobject.first;
-       while(go) {
-               ok= go->okey.first;
-               while(ok) {
-                       if(ok->gkey==group->active) {
-                               set_object_key(go->ob, ok);
-                               break;
-                       }
-                       ok= ok->next;
-               }
-               go= go->next;
+       for(go= group->gobject.first; go; go= go->next) {
+               if(go->ob==ob) 
+                       return 1;
        }
-       
+       return 0;
 }
 
 Group *find_group(Object *ob)
 {
        Group *group= G.main->group.first;
-       GroupObject *go;
        
        while(group) {
-
-               go= group->gobject.first;
-               while(go) {
-                       if(go->ob==ob) return group;
-                       go= go->next;
-               }
+               if(object_in_group(ob, group))
+                       return group;
                group= group->id.next;
        }
        return NULL;
 }
-
-void set_group_key_name(Group *group, char *name)
-{
-       GroupKey *gk;
-       
-       if(group==NULL) return;
-       
-       gk= group->gkey.first;
-       while(gk) {
-               if(strcmp(name, gk->name)==0) break;
-               gk= gk->next;
-       }
-       
-       if(gk) {
-               group->active= gk;
-               set_group_key(group);
-       }
-}
-
-void set_group_key_frame(Group *group, float frame)
-{
-       GroupObject *go;
-       
-       if(group==NULL) return;
-
-       go= group->gobject.first;
-       while(go) {
-               where_is_object_time(go->ob, frame);
-               go= go->next;
-       }
-}
index d303a7ed5bd59c250778937d1db6db2ff480131e..c9c1b4fa98d17c163ed3e7f30c743f10fd0ebe47 100644 (file)
 #include <string.h>
 #include "MEM_guardedalloc.h"
 
+#include "DNA_curve_types.h"
 #include "DNA_material_types.h"
-#include "DNA_texture_types.h"
 #include "DNA_mesh_types.h"
-#include "DNA_object_types.h"
-#include "DNA_curve_types.h"
 #include "DNA_meta_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
 
 #include "BLI_blenlib.h"
 
 #include "BKE_bad_level_calls.h"
-#include "BKE_utildefines.h"
-
+#include "BKE_blender.h"
+#include "BKE_displist.h"
 #include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "BKE_mesh.h"
 #include "BKE_library.h"
-#include "BKE_displist.h"
+#include "BKE_main.h"
 #include "BKE_material.h"
+#include "BKE_mesh.h"
+#include "BKE_utildefines.h"
 
 #include "BPY_extern.h"
 
+/* not material itself */
 void free_material(Material *ma)
 {
-       int a;
+       MaterialLayer *ml;
        MTex *mtex;
+       int a;
 
        BPY_free_scriptlink(&ma->scriptlink);
        
@@ -74,6 +75,11 @@ void free_material(Material *ma)
        
        if(ma->ramp_col) MEM_freeN(ma->ramp_col);
        if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
+       
+       for(ml= ma->layers.first; ml; ml= ml->next)
+               if(ml->mat) ml->mat->id.us--;
+       
+       BLI_freelistN(&ma->layers);
 }
 
 void init_material(Material *ma)
@@ -115,9 +121,10 @@ void init_material(Material *ma)
        
        ma->rampfac_col= 1.0;
        ma->rampfac_spec= 1.0;
-       ma->pr_lamp= 3; // two lamps, is bits
-       
-       ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_TANGENT_STR;
+       ma->pr_lamp= 3;                 /* two lamps, is bits */
+       ma->ml_flag= ML_RENDER; /* default render base material for layers */
+
+       ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR;
 }
 
 Material *add_material(char *name)
@@ -134,6 +141,7 @@ Material *add_material(char *name)
 Material *copy_material(Material *ma)
 {
        Material *man;
+       MaterialLayer *ml;
        int a;
        
        man= copy_libblock(ma);
@@ -149,9 +157,14 @@ Material *copy_material(Material *ma)
        }
        
        BPY_copy_scriptlink(&ma->scriptlink);
+       
        if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
        if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
        
+       duplicatelist(&man->layers, &ma->layers);
+       for(ml= man->layers.first; ml; ml= ml->next)
+               id_us_plus((ID *)ml->mat);
+
        return man;
 }
 
@@ -245,9 +258,25 @@ void make_local_material(Material *ma)
                new_id(0, (ID *)ma, 0);
        }
        else if(local && lib) {
+               Material *mat;
+               MaterialLayer *ml;
+               
                man= copy_material(ma);
                man->id.us= 0;
                
+               /* do material layers */
+               for(mat= G.main->mat.first; mat; mat= mat->id.next) {
+                       if(mat->id.lib==NULL) {
+                               for(ml= mat->layers.first; ml; ml= ml->next) {
+                                       if(ml->mat==ma) {
+                                               ml->mat= man;
+                                               man->id.us++;
+                                               ma->id.us--;
+                                       }
+                               }
+                       }
+               }
+               
                /* do objects */
                ob= G.main->object.first;
                while(ob) {
@@ -534,6 +563,18 @@ void new_material_to_objectdata(Object *ob)
        ob->actcol= ob->totcol;
 }
 
+Material *get_active_matlayer(Material *ma)
+{
+       MaterialLayer *ml;
+       
+       if(ma==NULL) return NULL;
+       
+       for(ml= ma->layers.first; ml; ml= ml->next)
+               if(ml->flag & ML_ACTIVE) break;
+       if(ml)
+               return ml->mat;
+       return ma;
+}
 
 void init_render_material(Material *ma)
 {
@@ -586,43 +627,30 @@ void init_render_material(Material *ma)
        ma->ambg= ma->amb*R.wrld.ambg;
        ma->ambb= ma->amb*R.wrld.ambb;
        
+       /* will become or-ed result of all layer modes */
+       ma->mode_l= ma->mode;
 }
 
 void init_render_materials()
 {
        Material *ma;
+       MaterialLayer *ml;
        
-       ma= G.main->mat.first;
-       while(ma) {
+       /* two steps, first initialize, then or the flags for layers */
+       for(ma= G.main->mat.first; ma; ma= ma->id.next) {
                if(ma->id.us) init_render_material(ma);
-               ma= ma->id.next;
        }
        
-}
-
-void end_render_material(Material *ma)
-{
-       /* XXXX obsolete? check! */
-       if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
-               if( !(ma->mode & MA_HALO) ) {
-                       ma->r= ma->g= ma->b= 1.0;
+       for(ma= G.main->mat.first; ma; ma= ma->id.next) {
+               for(ml= ma->layers.first; ml; ml= ml->next) {
+                       if(ml->mat) {
+                               ma->texco |= ml->mat->texco;
+                               ma->mode_l |= ml->mat->mode;
+                       }
                }
-       }
-}
-
-void end_render_materials()
-{
-       Material *ma;
-       
-       ma= G.main->mat.first;
-       while(ma) {
-               if(ma->id.us) end_render_material(ma);
-               ma= ma->id.next;
-       }
-       
+       }       
 }
 
-
 /* ****************** */
 
 char colname_array[125][20]= {
index 957d76d786b9fd05ba9571f1b2e8ed4ea3fbeeae..7c19f48e2e06762e243e395b5d2ae6482499e159 100644 (file)
@@ -55,6 +55,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_nla_types.h"
 #include "DNA_object_types.h"
 #include "DNA_object_force.h"
 #include "DNA_object_fluidsim.h"
@@ -888,6 +889,7 @@ Object *copy_object(Object *ob)
 
 void expand_local_object(Object *ob)
 {
+       bActionStrip *strip;
        int a;
        
        id_lib_extern((ID *)ob->action);
@@ -897,6 +899,10 @@ void expand_local_object(Object *ob)
        for(a=0; a<ob->totcol; a++) {
                id_lib_extern((ID *)ob->mat[a]);
        }
+       for (strip=ob->nlastrips.first; strip; strip=strip->next) {
+               id_lib_extern((ID *)strip->act);
+       }
+
 }
 
 void make_local_object(Object *ob)
index 53b4a09d89bc79b8c9a4e90ce72f7b60d992fb55..2cd387d7d936a70f4d35c72b36cdef66f703bfe8 100644 (file)
@@ -220,16 +220,16 @@ Scene *add_scene(char *name)
        return sce;
 }
 
-int object_in_scene(Object *ob, Scene *sce)
+Base *object_in_scene(Object *ob, Scene *sce)
 {
        Base *base;
        
        base= sce->base.first;
        while(base) {
-               if(base->object == ob) return 1;
+               if(base->object == ob) return base;
                base= base->next;
        }
-       return 0;
+       return NULL;
 }
 
 void set_scene_bg(Scene *sce)
index 5b98a3bf794faf562dbb4e64f2caa8ef9eeab86d..d81c0e94944e1fa45047095af80c6728491245a8 100644 (file)
@@ -546,7 +546,7 @@ static void softbody_calc_forces(Object *ob, float forcetime)
        
        /* check! */
        do_deflector= is_there_deflection(ob->lay);
-       do_effector= pdInitEffectors(ob);
+       do_effector= pdInitEffectors(ob, NULL);
        
        iks  = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
        bproot= sb->bpoint; /* need this for proper spring addressing */
index ceb226f67fb0a1fce71dacde78ee8a2f94a902b3..8c7fd8de05317c19ed806a50f2f483d2621b5775 100644 (file)
@@ -83,7 +83,7 @@ static IDType idtypes[]= {
        { ID_AR,                "Armature", IDTYPE_FLAGS_ISLINKABLE}, 
        { ID_CA,                "Camera",       IDTYPE_FLAGS_ISLINKABLE}, 
        { ID_CU,                "Curve",        IDTYPE_FLAGS_ISLINKABLE}, 
-       { ID_GR,                "Group",        0}, 
+       { ID_GR,                "Group",        IDTYPE_FLAGS_ISLINKABLE}, 
        { ID_ID,                "ID",           0}, 
        { ID_IM,                "Image",        IDTYPE_FLAGS_ISLINKABLE}, 
        { ID_IP,                "Ipo",          IDTYPE_FLAGS_ISLINKABLE}, 
index 1fb001636444c91f476e3f3480bc08b295b61b62..bd9709edb5e80699bab29561c01717c6df63519e 100644 (file)
@@ -1,19 +1,12 @@
 /*
- * readfile.c
- *
- * .blend file reading
- *
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,7 +24,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  *
  */
 
@@ -1983,6 +1976,7 @@ static void direct_link_texture(FileData *fd, Tex *tex)
 static void lib_link_material(FileData *fd, Main *main)
 {
        Material *ma;
+       MaterialLayer *ml;
        MTex *mtex;
        int a;
 
@@ -2000,6 +1994,10 @@ static void lib_link_material(FileData *fd, Main *main)
                                }
                        }
                        lib_link_scriptlink(fd, &ma->id, &ma->scriptlink);
+                       
+                       for (ml=ma->layers.first; ml; ml=ml->next)
+                               ml->mat= newlibadr_us(fd, ma->id.lib, ml->mat);
+                               
                        ma->id.flag -= LIB_NEEDLINK;
                }
                ma= ma->id.next;
@@ -2010,8 +2008,6 @@ static void direct_link_material(FileData *fd, Material *ma)
 {
        int a;
 
-       direct_link_scriptlink(fd, &ma->scriptlink);
-
        for(a=0; a<MAX_MTEX; a++) {
                ma->mtex[a]= newdataadr(fd, ma->mtex[a]);
        }
@@ -2019,6 +2015,10 @@ static void direct_link_material(FileData *fd, Material *ma)
        ma->ramp_col= newdataadr(fd, ma->ramp_col);
        ma->ramp_spec= newdataadr(fd, ma->ramp_spec);
        
+       direct_link_scriptlink(fd, &ma->scriptlink);
+       
+       link_list(fd, &ma->layers);
+
 }
 
 /* ************ READ MESH ***************** */
@@ -2129,6 +2129,7 @@ static void lib_link_modifiers(FileData *fd, Object *ob)
 static void lib_link_object(FileData *fd, Main *main)
 {
        Object *ob;
+       PartEff *paf;
        bSensor *sens;
        bController *cont;
        bActuator *act;
@@ -2143,7 +2144,8 @@ static void lib_link_object(FileData *fd, Main *main)
                        ob->track= newlibadr(fd, ob->id.lib, ob->track);
                        ob->ipo= newlibadr_us(fd, ob->id.lib, ob->ipo);
                        ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
-
+                       ob->dup_group= newlibadr_us(fd, ob->id.lib, ob->dup_group);
+                       
                        poin= ob->data;
                        ob->data= newlibadr_us(fd, ob->id.lib, ob->data);
 
@@ -2164,6 +2166,11 @@ static void lib_link_object(FileData *fd, Main *main)
                        lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
                        lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels);
 
+                       for(paf= ob->effect.first; paf; paf= paf->next) {
+                               if(paf->type==EFF_PARTICLE) {
+                                       paf->group= newlibadr_us(fd, ob->id.lib, paf->group);
+                               }
+                       }                               
 
                        sens= ob->sensors.first;
                        while(sens) {
@@ -2337,7 +2344,7 @@ static void direct_link_object(FileData *fd, Object *ob)
        paf= ob->effect.first;
        while(paf) {
                if(paf->type==EFF_PARTICLE) {
-                       paf->keys= 0;
+                       paf->keys= NULL;
                }
                if(paf->type==EFF_WAVE) {
                        WaveEff *wav = (WaveEff*) paf;
@@ -2496,7 +2503,6 @@ static void lib_link_scene(FileData *fd, Main *main)
                        sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
                        sce->set= newlibadr(fd, sce->id.lib, sce->set);
                        sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima);
-                       sce->group= newlibadr_us(fd, sce->id.lib, sce->group);
 
                        base= sce->base.first;
                        while(base) {
@@ -3140,30 +3146,13 @@ static void lib_link_sound(FileData *fd, Main *main)
 
 static void direct_link_group(FileData *fd, Group *group)
 {
-       GroupObject *go;
-       ObjectKey *ok;
-
        link_list(fd, &group->gobject);
-       link_list(fd, &group->gkey);
-       group->active= newdataadr(fd, group->active);
-
-       go= group->gobject.first;
-       while(go) {
-               link_list(fd, &go->okey);
-               ok= go->okey.first;
-               while(ok) {
-                       ok->gkey= newdataadr(fd, ok->gkey);
-                       ok= ok->next;
-               }
-               go= go->next;
-       }
 }
 
 static void lib_link_group(FileData *fd, Main *main)
 {
        Group *group= main->group.first;
        GroupObject *go;
-       ObjectKey *ok;
 
        while(group) {
                if(group->id.flag & LIB_NEEDLINK) {
@@ -3172,15 +3161,12 @@ static void lib_link_group(FileData *fd, Main *main)
                        go= group->gobject.first;
                        while(go) {
                                go->ob= newlibadr(fd, group->id.lib, go->ob);
-                               ok= go->okey.first;
-                               while(ok) {
-                                       ok->parent= newlibadr(fd, group->id.lib, ok->parent);
-                                       ok->track= newlibadr(fd, group->id.lib, ok->track);
-                                       ok->ipo= newlibadr_us(fd, group->id.lib, ok->ipo);
-                                       ok= ok->next;
-                               }
+                               /* groups have inverse users... */
+                               if(go->ob && group->id.us==0)
+                                       group->id.us= 1;
                                go= go->next;
                        }
+                       rem_from_group(group, NULL);    /* removes NULL entries */
                }
                group= group->id.next;
        }
@@ -5082,6 +5068,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                if(ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF;
                                ma->pad= 1;
                        }
+                       /* orange stuff, so should be done for 2.40 too */
+                       if(ma->layers.first==NULL) {
+                               ma->ml_flag= ML_RENDER;
+                       }
                }
        }
        
@@ -5287,6 +5277,15 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
        }
 }
 
+static void expand_group(FileData *fd, Main *mainvar, Group *group)
+{
+       GroupObject *go;
+       
+       for(go= group->gobject.first; go; go= go->next) {
+               expand_doit(fd, mainvar, go->ob);
+       }
+}
+
 static void expand_key(FileData *fd, Main *mainvar, Key *key)
 {
        expand_doit(fd, mainvar, key->ipo);
@@ -5301,6 +5300,7 @@ static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
 
 static void expand_material(FileData *fd, Main *mainvar, Material *ma)
 {
+       MaterialLayer *ml;
        int a;
 
        for(a=0; a<MAX_MTEX; a++) {
@@ -5309,7 +5309,13 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
                        expand_doit(fd, mainvar, ma->mtex[a]->object);
                }
        }
+       
        expand_doit(fd, mainvar, ma->ipo);
+       
+       for (ml=ma->layers.first; ml; ml=ml->next) {
+               if(ml->mat)
+                       expand_doit(fd, mainvar, ml->mat);
+       }
 }
 
 static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
@@ -5718,6 +5724,9 @@ static void expand_main(FileData *fd, Main *mainvar)
                                        case ID_AC:
                                                expand_action(fd, mainvar, (bAction *)id);
                                                break;
+                                       case ID_GR:
+                                               expand_group(fd, mainvar, (Group *)id);
+                                               break;
                                        }
 
                                        doit= 1;
@@ -5747,8 +5756,9 @@ static void give_base_to_objects(Scene *sce, ListBase *lb)
                                BLI_addtail(&(sce->base), base);
                                base->lay= ob->lay;
                                base->object= ob;
+                               base->flag= ob->flag;
                                ob->id.us= 1;
-
+                               
                                ob->id.flag -= LIB_INDIRECT;
                                ob->id.flag |= LIB_EXTERN;
 
index f941b5f77d2d0b12f51ef2b884d2769e0c9cea31..d2e1d7e2c6c976f1416f1f4b5a4fb0c9f84d0842 100644 (file)
@@ -994,6 +994,7 @@ static void write_textures(WriteData *wd, ListBase *idbase)
 static void write_materials(WriteData *wd, ListBase *idbase)
 {
        Material *ma;
+       MaterialLayer *ml;
        int a;
 
        ma= idbase->first;
@@ -1010,6 +1011,10 @@ static void write_materials(WriteData *wd, ListBase *idbase)
                        if(ma->ramp_spec) writestruct(wd, DATA, "ColorBand", 1, ma->ramp_spec);
                        
                        write_scriptlink(wd, &ma->scriptlink);
+                       
+                       for (ml=ma->layers.first; ml; ml=ml->next)
+                               writestruct(wd, DATA, "MaterialLayer", 1, ml);
+
                }
                ma= ma->id.next;
        }
@@ -1487,9 +1492,7 @@ static void write_sounds(WriteData *wd, ListBase *idbase)
 static void write_groups(WriteData *wd, ListBase *idbase)
 {
        Group *group;
-       GroupKey *gk;
        GroupObject *go;
-       ObjectKey *ok;
 
        group= idbase->first;
        while(group) {
@@ -1497,27 +1500,11 @@ static void write_groups(WriteData *wd, ListBase *idbase)
                        /* write LibData */
                        writestruct(wd, ID_GR, "Group", 1, group);
 
-                       gk= group->gkey.first;
-                       while(gk) {
-                               writestruct(wd, DATA, "GroupKey", 1, gk);
-                               gk= gk->next;
-                       }
-
                        go= group->gobject.first;
                        while(go) {
                                writestruct(wd, DATA, "GroupObject", 1, go);
                                go= go->next;
                        }
-                       go= group->gobject.first;
-                       while(go) {
-                               ok= go->okey.first;
-                               while(ok) {
-                                       writestruct(wd, DATA, "ObjectKey", 1, ok);
-                                       ok= ok->next;
-                               }
-                               go= go->next;
-                       }
-
                }
                group= group->id.next;
        }
index 176bf8c8e68f3ec20cc6b39aba2baa020c589918..f8c73dfdea2a67f6b2c5720ab163a1a80e7a94da 100644 (file)
 #define BDR_UNWRAPPER_H
 
 void set_seamtface(void); /* set TF_SEAM flags in tfaces */
-void unwrap_lscm(void); /* unwrap selected tfaces */
-void unwrap_lscm_live(void); /* unwrap selected tfaces (for live mode, with no undo pushes) */
 void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index);
 
+void unwrap_lscm(void); /* unwrap faces selected in 3d view */
+void unwrap_lscm_new(void);
+void minimize_stretch_tface_uv(void); /* optimize faces selected in uv editor */
+
+/* for live mode: no undo pushes, caching for quicky re-unwrap */
+void unwrap_lscm_live_begin(void);
+void unwrap_lscm_live_re_solve(void);
+void unwrap_lscm_live_end(void);
+
 #endif /* BDR_UNWRAPPER_H */
 
index 01102649fd6197c7fddfa67502b452e3d824acc8..e86bd962a6ce9760223d06d4881a4363eedeca52 100644 (file)
  */
 
 struct Group;
-void set_active_group(void);
-void add_selected_to_group(void);
+
+void add_selected_to_group(struct Group *group);
 void rem_selected_from_group(void);
-void prev_group_key(struct Group *group);
-void next_group_key(struct Group *group);
-void select_group_menu(void);
-void select_group(short nr);
+void group_operation_with_menu(void);
+
index b5f5a91c50c5ab7b5c64d8a1ea09b5c332c48802..8df5e7255a5e8cc38e5643bfecff9ef21ce94a6c 100644 (file)
@@ -34,6 +34,7 @@
 #define BIF_MESHTOOLS_H
 
 struct Object;
+struct EditVert;
 
 extern void join_mesh(void);
 
@@ -42,8 +43,9 @@ extern void slowerdraw(void);
 
 extern void sort_faces(void);
 
-extern int mesh_octree_table(struct Object *ob, float *co, char mode);
+extern long mesh_octree_table(struct Object *ob, float *co, char mode);
 extern int mesh_get_x_mirror_vert(struct Object *ob, int index);
+extern struct EditVert *editmesh_get_x_mirror_vert(struct Object *ob, float *co);
 
 #endif
 
index 8c05d96ec722c04d6247843017e66ea78796cf27..b9b1d1f63bf50e4828e9a920f21a5ea7127803e8 100644 (file)
@@ -117,8 +117,8 @@ typedef enum {
        ICON_ENVMAP,
        ICON_TRANSP_HLT,
        ICON_TRANSP_DEHLT,
-       ICON_RADIO_DEHLT,
-       ICON_RADIO_HLT,
+       ICON_CIRCLE_DEHLT,
+       ICON_CIRCLE_HLT,
        ICON_TPAINT_DEHLT,
        ICON_TPAINT_HLT,
        ICON_WPAINT_DEHLT,
index b51d844403c80878143bf854ccc017055a928e2f..7970ed5e41ddd0b3eb52ed94da1aff6675a060b4 100644 (file)
@@ -114,8 +114,7 @@ extern       void newspace(struct ScrArea *sa, int type);
 extern       void set_rects_butspace(struct SpaceButs *buts);
 extern       void test_butspace(void);
 extern       void start_game(void);
-extern          void select_group_menu(void);
-extern          void select_group(short nr);
+extern          void select_grouped(short nr);
 
 extern                 void BIF_undo_push(char *str);
 extern                 void BIF_undo(void);
index ab36972ea18ef8a33d06b1fdc6b1dcdd4a7e6ba2..05e06afca4e953f43714ffaa9943d3a8d005619c 100644 (file)
 #define B_AUTOFGON             32
 #define B_KNIFE                        0x80
 #define B_PERCENTSUBD  0x40
-
+#define B_MESH_X_MIRROR        0x100
 
 /* DISPLAYMODE */
 #define R_DISPLAYVIEW  0
index 33a074ba46d9f8dd58814743140497f9a201d12c..8e72198da52f38b0c3621939ac7126c659d81160 100644 (file)
@@ -121,6 +121,8 @@ void test_scenepoin_but(char *name, struct ID **idpp);
 void test_matpoin_but(char *name, struct ID **idpp);
 void test_scriptpoin_but(char *name, struct ID **idpp);
 void test_actionpoin_but(char *name, ID **idpp);
+void test_grouppoin_but(char *name, ID **idpp);
+
 void test_idbutton_cb(void *namev, void *arg2_unused);
 
 /* -------------- internal event defines ------------ */
@@ -155,6 +157,8 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
 #define B_SBUFF                        1104
 #define B_SHADBUF              1105
 #define B_SHADRAY              1106
+#define B_LMTEXPASTE   1107
+#define B_LMTEXCOPY            1108
 
 /* *********************** */
 #define B_MATBUTS              1300
@@ -178,6 +182,8 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
 /* yafray: material preset menu event */
 #define B_MAT_YF_PRESET        1217
 
+#define B_MAT_LAYERBROWSE      1218
+
 /* *********************** */
 #define B_TEXBUTS              1400
 
@@ -218,7 +224,7 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
 #define B_ENV_FREE_ALL         1357
 #define B_UNLINKIMA            1358
 
-/* *********************** */
+/* **************** animbuts = object buttons ******* */
 #define B_ANIMBUTS             1500
 
 #define B_RECALCPATH   1401
@@ -234,21 +240,22 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
 #define B_SOFTBODY_BAKE                        1422
 #define B_SOFTBODY_BAKE_FREE   1423
 
-       /* this has MAX_EFFECT settings! Next free define is 1450... */
-#define B_SELEFFECT    1430    
+/* this has MAX_EFFECT settings! Next free define is 1450... */
+#define B_SELEFFECT    1430
 
 /* Fluidsim button defines */
 #define B_FLUIDSIM_BAKE                1450
-#define B_FLUIDSIM_SELDIR            1451
+#define B_FLUIDSIM_SELDIR          1451
 #define B_FLUIDSIM_FORCEREDRAW 1452
 
-
 /* *********************** */
 #define B_WORLDBUTS            1600
 
 #define B_TEXCLEARWORLD        1501
 #define B_COLHOR               1502
 #define B_COLZEN               1503
+#define B_WMTEXPASTE   1504
+#define B_WMTEXCOPY            1505
 
 
 /* *********************** */
index 463fceaa0a1fd26e4d721fd23c0caaecc2dcc848..c8781a75e2eb8ab2a2575f9989cd0a6d067b5436 100755 (executable)
@@ -125,6 +125,7 @@ typedef struct TransData {
        struct Object *ob;
        TransDataExtension *ext;        /* for objects, poses. 1 single malloc per TransInfo! */
        TransDataIpokey *tdi;           /* for objects, ipo keys. per transdata a malloc */
+       void *tdmir;             /* mirrored element pointer, in editmode mesh to EditVert */
     short  flag;         /* Various flags */
        short  protectflag;      /* If set, copy of Object or PoseChannel protection */
 } TransData;
index 46ce9b7d017fa1e4e2f0f6fbbc28c35027e5d698..86ffb0fc4add5874e32567d97a0c39877bb1c1f1 100644 (file)
@@ -104,6 +104,7 @@ typedef struct Particle {
        short mat_nr, rt;
 } Particle;
 
+struct Group;
 
 typedef struct PartEff {
        struct PartEff *next, *prev;
@@ -125,7 +126,9 @@ typedef struct PartEff {
        short disp, vertgroup_v;
        
        char vgroupname[32], vgroupname_v[32];
+       
        Particle *keys;
+       struct Group *group;
        
 } PartEff;
 
index f713910147620c4a3494473a00eafcba17a56c09..2ee699839edc1518b037a2a192912519bb82c30e 100644 (file)
 #include "DNA_ID.h"
 
 struct Object;
-struct Ipo;
-
-typedef struct GroupKey {
-       struct GroupKey *next, *prev;
-       short sfra, efra;
-       float cfra;
-       char name[32];
-} GroupKey;
-
-typedef struct ObjectKey {
-       struct ObjectKey *next, *prev;
-       GroupKey *gkey;         /* for reference */
-
-       /* copy of relevant data */
-       short partype, pad;
-       int par1, par2, par3;
-       
-       struct Object *parent, *track;
-       struct Ipo *ipo;
-
-       /* this block identical to object */    
-       float loc[3], dloc[3], orig[3];
-       float size[3], dsize[3];
-       float rot[3], drot[3];
-       float quat[4], dquat[4];
-       float obmat[4][4];
-       float parentinv[4][4];
-       float imat[4][4];       /* voor bij render, tijdens simulate, tijdelijk: ipokeys van transform  */
-       
-       unsigned int lay;                               /* kopie van Base */
-       
-       char transflag, ipoflag;
-       char trackflag, upflag;
-       
-       float sf, ctime, padf;
-               
-
-} ObjectKey;
 
 typedef struct GroupObject {
        struct GroupObject *next, *prev;
        struct Object *ob;
-       ListBase okey;          /* ObjectKey */
-       
+       void *lampren;          /* used while render */
 } GroupObject;
 
 
@@ -89,11 +50,9 @@ typedef struct Group {
        ID id;
        
        ListBase gobject;       /* GroupObject */
-       ListBase gkey;          /* GroupKey */
-       
-       GroupKey *active;
        
 } Group;
 
+
 #endif
 
index 5ef327502e1491ff1afaa534f5b82838946265c4..bbe7d0f8125e43be30c469d1bf546615370462dc 100644 (file)
 #ifndef DNA_MATERIAL_TYPES_H
 #define DNA_MATERIAL_TYPES_H
 
-/*  #include "BLI_listBase.h" */
-
 #include "DNA_ID.h"
 #include "DNA_scriptlink_types.h"
+#include "DNA_listBase.h"
 
 #ifndef MAX_MTEX
 #define MAX_MTEX       10
@@ -47,6 +46,17 @@ struct MTex;
 struct Ipo;
 struct Material;
 struct ColorBand;
+struct Group;
+
+typedef struct MaterialLayer {
+       struct MaterialLayer *next, *prev;
+       
+       struct Material *mat;
+       float blendfac;
+       short flag, blendmethod, menunr, pad;
+       int pad2;
+       
+} MaterialLayer;
 
 /* WATCH IT: change type? also make changes in ipo.h  */
 
@@ -54,14 +64,16 @@ typedef struct Material {
        ID id;
        
        short colormodel, lay;          /* lay: for dynamics (old engine, until 2.04) */
+       /* note, keep this below synced with render_types.h */
        float r, g, b;
        float specr, specg, specb;
        float mirr, mirg, mirb;
        float ambr, ambb, ambg;
-       
        float amb, emit, ang, spectra, ray_mirror;
        float alpha, ref, spec, zoffs, add;
        float translucency;
+       /* end synced with render_types.h */
+       
        float fresnel_mir, fresnel_mir_i;
        float fresnel_tra, fresnel_tra_i;
        float filter;           /* filter added, for raytrace transparency */
@@ -69,16 +81,15 @@ typedef struct Material {
        short har;
        char seed1, seed2;
        
-       int mode; 
-       int mode2; /* even more material settings :) */
+       int mode, mode_l;               /* mode_l is the or-ed result of all layer modes */
        short flarec, starc, linec, ringc;
        float hasize, flaresize, subsize, flareboost;
        float strand_sta, strand_end, strand_ease;
+       float pad1;
        
        /* for buttons and render*/
        char rgbsel, texact, pr_type, pad;
-       short pr_back, pr_lamp, septex, pad4;
-       int pad5;
+       short pr_back, pr_lamp, septex, ml_flag;        /* ml_flag is for disable base material */
        
        /* shaders */
        short diff_shader, spec_shader;
@@ -97,7 +108,9 @@ typedef struct Material {
        float rampfac_col, rampfac_spec;
 
        struct MTex *mtex[10];
+       ListBase layers;
        struct Ipo *ipo;
+       struct Group *group;
        
        /* dynamic properties */
        float friction, fh, reflect;
@@ -107,7 +120,7 @@ typedef struct Material {
        /* yafray: absorption color, dispersion parameters and material preset menu */
        float YF_ar, YF_ag, YF_ab, YF_dscale, YF_dpwr;
        int YF_dsmp, YF_preset, YF_djit;
-
+       
        ScriptLink scriptlink;
 } Material;
 
@@ -161,7 +174,8 @@ typedef struct Material {
 #define MA_DIFF_LAMBERT                0
 #define MA_DIFF_ORENNAYAR      1
 #define MA_DIFF_TOON           2
-#define MA_DIFF_MINNAERT        3
+#define MA_DIFF_MINNAERT    3
+#define MA_DIFF_FRESNEL     4
 
 /* spec_shader */
 #define MA_SPEC_COOKTORR       0
@@ -224,6 +238,7 @@ typedef struct Material {
 #define MAP_AMB                        2048
 #define MAP_DISPLACE   4096
 #define MAP_WARP               8192
+#define MAP_LAYER              16384
 
 /* pr_type */
 #define MA_FLAT                        0
@@ -233,5 +248,13 @@ typedef struct Material {
 /* pr_back */
 #define MA_DARK                        1
 
+/* MaterialLayer flag */
+#define ML_ACTIVE              1
+#define ML_RENDER              2
+#define ML_NEG_NORMAL  4
+#define ML_DIFFUSE             8
+#define ML_SPECULAR            16
+#define ML_ALPHA               32
+
 #endif
 
index 1d16015a628e63c2be77b196fd7de5c1ae96028a..88075e718debd30215be51b7e6e6731238e50df4 100644 (file)
@@ -188,10 +188,7 @@ typedef struct Object {
        
        struct PartDeflect *pd;         /* particle deflector/attractor/collision data */
        struct SoftBody *soft;          /* if exists, saved in file */
-       struct Life *life;
-
-       LBuf lbuf;
-       LBuf port;
+       struct Group *dup_group;        /* object duplicator for group */
        
        short fluidsimFlag;                     /* NT toggle fluidsim participation on/off */
        char shapenr, shapeflag;        /* current shape key for menu or pinned, flag for pinning */
@@ -262,13 +259,13 @@ extern Object workob;
 #define OB_OFFS_LOCAL  1
 #define OB_QUAT                        2
 #define OB_NEG_SCALE   4
-#define OB_DUPLI               (8+16)
+#define OB_DUPLI               (8+16+256)
 #define OB_DUPLIFRAMES 8
 #define OB_DUPLIVERTS  16
 #define OB_DUPLIROT            32
 #define OB_DUPLINOSPEED        64
-
 #define OB_POWERTRACK  128
+#define OB_DUPLIGROUP  256
 
 /* (short) ipoflag */
 #define OB_DRAWKEY                     1
index fe54a631bdd6eb08fa7e2db023298ac0c8a085e7..968aa6abe56b1f15c601a31b38c4ecc324ab7c7c 100644 (file)
@@ -289,7 +289,6 @@ typedef struct Scene {
        
        ListBase base;
        struct Base *basact;
-       struct Group *group;
        
        float cursor[3];
        float twcent[3];                        /* center for transform widget */
@@ -407,33 +406,6 @@ typedef struct Scene {
 #define R_RADHDR       21
 #define R_TIFF         22
 
-/* **************** RENDER ********************* */
-/* mode flag is same as for renderdata */
-/* flag */
-#define R_ZTRA                 1
-#define R_HALO                 2
-#define R_SEC_FIELD            4
-#define R_LAMPHALO             8
-#define R_RENDERING            16
-#define R_ANIMRENDER   32
-#define R_REDRAW_PRV   64
-
-/* vlakren->flag (vlak = face in dutch) char!!! */
-#define R_SMOOTH               1
-#define R_VISIBLE              2
-       /* strand flag, means special handling */
-#define R_STRAND               4
-#define R_NOPUNOFLIP   8
-#define R_FULL_OSA             16
-#define R_FACE_SPLIT   32
-       /* Tells render to divide face other way. */
-#define R_DIVIDE_24            64      
-       /* vertex normals are tangent or view-corrected vector, for hair strands */
-#define R_TANGENT              128             
-
-/* vertren->texofs (texcoordinate offset relative to vertren->orco */
-#define R_UVOFS3       1
-
 /* **************** SCENE ********************* */
 #define RAD_PHASE_PATCHES      1
 #define RAD_PHASE_FACES                2
index 7007981ff640f72b639321cccfc4bde0b6b8f76b..5a7e84c62ef4d173bdf442f4e92b5cd0905b3df6 100644 (file)
@@ -483,6 +483,7 @@ typedef struct SpaceImaSel {
 #define SO_SELECTED            3
 #define SO_ACTIVE              4
 #define SO_SAME_TYPE   5
+#define SO_GROUPS              6
 
 /* SpaceOops->storeflag */
 #define SO_TREESTORE_CLEANUP   1
index e284044a633530c00f03094929ceae2be83f2da4..edc621ba7582175231fc046df1e00c988771c405 100644 (file)
@@ -152,12 +152,13 @@ typedef struct World {
 #define WOMAP_HORIZ            2
 #define WOMAP_ZENUP            4
 #define WOMAP_ZENDOWN  8
+#define WOMAP_MIST             16
 
 /* physicsEngine */
 #define WOPHY_NONE             0
 #define WOPHY_ENJI             1
 #define WOPHY_SUMO             2
-#define WOPHY_DYNAMO           3
+#define WOPHY_DYNAMO   3
 #define WOPHY_ODE              4
 #define WOPHY_BULLET   5
 
index e3eb926192c27970f146c0a4b4e8471e7ab9b836..ec724b55846c8f260fa527b929dd8fabdffcd5c4 100644 (file)
@@ -148,9 +148,7 @@ struct MTex;
 struct Tex;
 
 void init_render_textures(void);
-void end_render_textures(void);
 void init_render_texture(struct Tex *tex);
-void end_render_texture(struct Tex *tex);
 
 void do_material_tex(ShadeInput *shi);
 void do_lamp_tex(struct LampRen *la, float *lavec, ShadeInput *shi, float *fcol);
@@ -162,7 +160,6 @@ void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg,
 /* envmap (4)                                                                   */
 /* ------------------------------------------------------------------------- */
 struct EnvMap;
-struct Tex;
 
 void    RE_free_envmapdata(struct EnvMap *env);
 void    RE_free_envmap(struct EnvMap *env);
@@ -173,6 +170,9 @@ struct EnvMap *RE_copy_envmap(struct EnvMap *env);
 /* --------------------------------------------------------------------- */
 /* rendercore (12)                                                        */
 /* --------------------------------------------------------------------- */
+struct MaterialLayer;
+struct ShadeResult;
+
 float Phong_Spec(float *n, float *l, float *v, int hard, int tangent);
 float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent);
 float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_power, int tangent);
@@ -182,12 +182,14 @@ float WardIso_Spec(float *n, float *l, float *v, float rms, int tangent);
 float OrenNayar_Diff(float *n, float *l, float *v, float rough);
 float Toon_Diff( float *n, float *l, float *v, float size, float smooth);
 float Minnaert_Diff( float nl, float *n, float *v, float darkness);
+float Fresnel_Diff(float *vn, float *lv, float *view, float ior, float fac);
 
 void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, float g, float b);
 void ramp_diffuse_result(float *diff, ShadeInput *shi);
 void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec);
 void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi);
 
+void matlayer_blend(struct MaterialLayer *ml, float blendfac, struct ShadeResult *target, struct ShadeResult *src);
 
 /* --------------------------------------------------------------------- */
 /* ray.c (2)                                                        */
index 3a09ba133ef7402e52d160c9a57017f036106047..531a7fc5ceba1e902f6aebcd8c1111d04b75f278 100644 (file)
@@ -1,15 +1,12 @@
 /**
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +24,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 #ifndef RENDER_TYPES_H
@@ -58,6 +55,15 @@ typedef struct TexResult {
        float *nor;
 } TexResult;
 
+/* localized shade result data */
+typedef struct ShadeResult 
+{
+       float diff[3];
+       float spec[3];
+       float alpha;
+       
+} ShadeResult;
+
 /* localized renderloop data */
 typedef struct ShadeInput
 {
@@ -79,10 +85,11 @@ typedef struct ShadeInput
        
        /* individual copies: */
        int har;
+       float layerfac;
        
        /* texture coordinates */
        float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3];
-       float vn[3], facenor[3], view[3], refcol[4], displace[3], strand, tang[3];
+       float vn[3], vno[3], facenor[3], view[3], refcol[4], displace[3], strand, tang[3];
        
        /* dx/dy OSA coordinates */
        float dxco[3], dyco[3];
@@ -139,6 +146,7 @@ typedef struct RE_Render
        int totvlak, totvert, tothalo, totlamp;
 
        /* internal, fortunately */
+       ListBase lights;
        struct LampRen **la;
        struct VlakRen **blovl;
        struct VertRen **blove;
@@ -194,9 +202,9 @@ typedef struct VertRen
        float *orco;
        float *sticky;
        void *svert;                    /* smooth vert, only used during initrender */
-       short clip, texofs;             /* texofs= flag */
-       float accum;                    /* accum for radio weighting, and for strand texco static particles */
+       short clip;     
        short flag;                             /* in use for clipping ztra parts */
+       float accum;                    /* accum for radio weighting, and for strand texco static particles */
 } VertRen;
 
 /* ------------------------------------------------------------------------- */
@@ -313,6 +321,34 @@ typedef struct LampRen
        struct MTex *mtex[MAX_MTEX];
 } LampRen;
 
+/* **************** defines ********************* */
+