Merge from trunk
authorAndre Susano Pinto <andresusanopinto@gmail.com>
Fri, 30 May 2008 20:33:33 +0000 (20:33 +0000)
committerAndre Susano Pinto <andresusanopinto@gmail.com>
Fri, 30 May 2008 20:33:33 +0000 (20:33 +0000)
svn merge  -r 14954:15064 https://svn.blender.org/svnroot/bf-blender/trunk/blender

55 files changed:
config/win32-vc-config.py
intern/ghost/intern/GHOST_WindowWin32.cpp
release/scripts/3ds_import.py
release/scripts/uv_from_adjacent.py [deleted file]
release/scripts/uv_seams_from_islands.py
release/scripts/uvcalc_lightmap.py
release/windows/installer/00.sconsblender.nsi
source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/object.c
source/blender/blenlib/intern/freetypefont.c
source/blender/blenlib/intern/psfont.c
source/blender/blenlib/intern/util.c
source/blender/include/BDR_editcurve.h
source/blender/include/transform.h
source/blender/makesdna/intern/makesdna.c
source/blender/nodes/intern/Makefile
source/blender/python/api2_2x/Draw.c
source/blender/python/api2_2x/Node.c
source/blender/python/api2_2x/Object.c
source/blender/python/api2_2x/Particle.c
source/blender/python/api2_2x/Scene.c
source/blender/python/api2_2x/doc/Object.py
source/blender/python/api2_2x/sceneRender.c
source/blender/render/extern/include/RE_raytrace.h
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/rayshade.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_shading.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/editarmature.c
source/blender/src/editcurve.c
source/blender/src/editnode.c
source/blender/src/interface.c
source/blender/src/meshtools.c
source/blender/src/poseobject.c
source/blender/src/sequence.c
source/blender/src/toets.c
source/blender/src/transform_conversions.c
source/blender/src/transform_manipulator.c
source/blender/src/transform_orientations.c
source/blender/src/view.c
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
source/gameengine/GamePlayer/common/GPC_RenderTools.h
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Rasterizer/RAS_IRenderTools.h
source/gameengine/Rasterizer/RAS_MaterialBucket.cpp

index 32b6597b5d55eda149f52615642cd376808585cf..02e5dbb7f8fa5438630388b93bdeac3c55ef9c81 100644 (file)
@@ -157,7 +157,7 @@ REL_CCFLAGS = ['-O2', '-DNDEBUG']
 C_WARN = []
 CC_WARN = []
 
-LLIBS = 'ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid'
+LLIBS = 'ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid'
 
 PLATFORM_LINKFLAGS = '''
                         /SUBSYSTEM:CONSOLE 
index 230df02c3594237a1584bc5bd685f1eb19d4231b..905b2f7ac6349487d6c1b6371690f3db4927ba27 100644 (file)
@@ -871,12 +871,25 @@ static int EnumPixelFormats(HDC hdc) {
        for(i=1; i<=n; i++) { /* not the idiom, but it's right */
                ::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
                w = WeightPixelFormat(pfd);
-               if(w > weight) {
-                       weight = w;
-                       iPixelFormat = i;
+               // be strict on stereo
+               if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO))   {
+                       if(w > weight) {
+                               weight = w;
+                               iPixelFormat = i;
+                       }
+               }
+       }
+       if (weight == 0) {
+               // we could find the correct stereo setting, just find any suitable format 
+               for(i=1; i<=n; i++) { /* not the idiom, but it's right */
+                       ::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
+                       w = WeightPixelFormat(pfd);
+                       if(w > weight) {
+                               weight = w;
+                               iPixelFormat = i;
+                       }
                }
        }
-       
        return iPixelFormat;
 }
 
index 8c7c93018dbbf5d5461077eaaa9012b5af18c39a..028b96336068c81514dfc148415fe7c3ef31615a 100644 (file)
@@ -419,7 +419,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
                                ob.setMatrix(contextMatrix_rot)
                        
                        importedObjects.append(ob)
-                       
+                       bmesh.calcNormals()
                
                for matName, faces in myContextMeshMaterials.iteritems():
                        makeMeshMaterialCopy(matName, faces)
@@ -664,9 +664,8 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
                        #print contextLamp.name, 
                        
                elif (new_chunk.ID==OBJECT_MESH):
-                       ## @@ PATCH
-                       print 'Found an OBJECT_MESH chunk'
-               
+                       # print 'Found an OBJECT_MESH chunk'
+                       pass
                elif (new_chunk.ID==OBJECT_VERTICES):
                        '''
                        Worldspace vertex locations
diff --git a/release/scripts/uv_from_adjacent.py b/release/scripts/uv_from_adjacent.py
deleted file mode 100644 (file)
index 285cca9..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#!BPY
-"""
-Name: 'UVs from unselected adjacent'
-Blender: 242
-Group: 'UVCalculation'
-Tooltip: 'Assign UVs to selected faces from surrounding unselected faces.'
-"""
-__author__ = "Campbell Barton"
-__url__ = ("blender", "blenderartists.org")
-__version__ = "1.0 2006/02/07"
-
-__bpydoc__ = """\
-This script sets the UV mapping and image of selected faces from adjacent unselected faces.
-
-Use this script in face select mode for texturing between textured faces.
-"""
-
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# Script copyright (C) Campbell J Barton
-#
-# 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 *****
-# --------------------------------------------------------------------------
-
-
-from Blender import *
-import bpy
-
-def mostUsedImage(imageList): # Returns the image most used in the list.
-       if not imageList:
-               return None
-       elif len(imageList) < 3:
-               return imageList[0]
-       
-       # 3+ Images, Get the most used image for surrounding faces.
-       imageCount = {}
-       for image in imageList:
-               if image:
-                       image_key= image.name
-               else:
-                       image_key = None
-               
-               try:
-                       imageCount[image_key]['imageCount'] +=1 # an extra user of this image
-               except:
-                       imageCount[image_key] = {'imageCount':1, 'blenderImage':image} # start with 1 user.
-       
-       # Now a list of tuples, (imageName, {imageCount, image})
-       imageCount = imageCount.items()
-       
-       try:    imageCount.sort(key=lambda a: a[1])
-       except: imageCount.sort(lambda a,b: cmp(a[1], b[1]))
-       
-       
-       return imageCount[-1][1]['blenderImage']        
-
-
-def main():
-       sce = bpy.data.scenes.active
-       ob = sce.objects.active
-       
-       if ob == None or ob.type != 'Mesh':
-               Draw.PupMenu('ERROR: No mesh object in face select mode.')
-               return
-       me = ob.getData(mesh=1)
-       
-       if not me.faceUV:
-               Draw.PupMenu('ERROR: No mesh object in face select mode.')
-               return
-       
-       selfaces = [f for f in me.faces if f.sel]
-       unselfaces = [f for f in me.faces if not f.sel]
-       
-       
-       # Gather per Vert UV and Image, store in vertUvAverage
-       vertUvAverage = [[[],[]] for i in xrange(len(me.verts))]
-       
-       for f in unselfaces: # Unselected faces only.
-               fuv = f.uv
-               for i,v in enumerate(f):
-                       vertUvAverage[v.index][0].append(fuv[i])
-                       vertUvAverage[v.index][1].append(f.image)
-                       
-       # Average per vectex UV coords
-       for vertUvData in vertUvAverage:
-               uvList = vertUvData[0]
-               if uvList:
-                       # Convert from a list of vectors into 1 vector.
-                       vertUvData[0] = reduce(lambda a,b: a+b, uvList, Mathutils.Vector(0,0)) * (1.0/len(uvList))
-               else:
-                       vertUvData[0] = None
-       
-       # Assign to selected faces
-       TEX_FLAG = Mesh.FaceModes['TEX']
-       for f in selfaces:
-               uvlist = []
-               imageList = []
-               for i,v in enumerate(f):
-                       uv, vImages = vertUvAverage[v.index]
-                       uvlist.append( uv )
-                       imageList.extend(vImages)
-               
-               if None not in uvlist:                  
-                       # all the faces images used by this faces vert. some faces will be added twice but thats ok.
-                       # Get the most used image and assign to the face.
-                       image = mostUsedImage(imageList) 
-                       f.uv = uvlist
-                       
-                       if image:
-                               f.image = image
-                               f.mode |= TEX_FLAG
-       Window.RedrawAll()
-       
-if __name__ == '__main__':
-       main()
\ No newline at end of file
index 241f38fc4aa83a0737fe755a0d5e003fb0fa8ac9..7f156efde7dbec4f5ea4d0fc31dfec3954b221a4 100644 (file)
@@ -1,12 +1,31 @@
 #!BPY
 """
 Name: 'Seams from Islands'
-Blender: 243
+Blender: 246
 Group: 'UV'
 Tooltip: 'Add seams onto the mesh at the bounds of UV islands'
 """
 
-# Add a licence here if you wish to re-distribute, we recommend the GPL
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Script copyright (C) Campbell Barton
+#
+# 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 *****
+# --------------------------------------------------------------------------
 
 from Blender import Scene, Mesh, Window, sys
 import BPyMessages
@@ -37,8 +56,11 @@ def seams_from_islands(me):
        # add seams
        SEAM = Mesh.EdgeFlags.SEAM
        for ed in me.edges:
-               if len(set(edge_uvs[ed.key])) > 1:
-                       ed.flag |= SEAM
+               try: # the edge might not be in a face
+                       if len(set(edge_uvs[ed.key])) > 1:
+                               ed.flag |= SEAM
+               except:
+                       pass
 
 def main():
        
index 5f9f88a241de1d798da1d860ed44a6a42cc773cb..37423b7197e2ac147a36ee76938b131ed4dfe481 100644 (file)
@@ -41,6 +41,12 @@ import BPyMesh
 
 from math import sqrt
 
+def AngleBetweenVecs(a1,a2):
+       try:
+               return Mathutils.AngleBetweenVecs(a1,a2)
+       except:
+               return 180.0
+
 class prettyface(object):
        __slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
        def __init__(self, data):
@@ -148,9 +154,9 @@ class prettyface(object):
                if len(uv) == 2:
                        # match the order of angle sizes of the 3d verts with the UV angles and rotate.
                        def get_tri_angles(v1,v2,v3):
-                               a1= Mathutils.AngleBetweenVecs(v2-v1,v3-v1)
-                               a2= Mathutils.AngleBetweenVecs(v1-v2,v3-v2)
-                               a3 = 180 - (a1+a2) #a3= Mathutils.AngleBetweenVecs(v2-v3,v1-v3)
+                               a1= AngleBetweenVecs(v2-v1,v3-v1)
+                               a2= AngleBetweenVecs(v1-v2,v3-v2)
+                               a3 = 180 - (a1+a2) #a3= AngleBetweenVecs(v2-v3,v1-v3)
                                
                                
                                return [(a1,0),(a2,1),(a3,2)]
@@ -237,8 +243,17 @@ PREF_MARGIN_DIV=           512):
                        face_groups.append(faces)
                
                if PREF_NEW_UVLAYER:
-                       me.addUVLayer('lightmap')
-                       me.activeUVLayer = 'lightmap'
+                       uvname_org = uvname = 'lightmap'
+                       uvnames = me.getUVLayerNames()
+                       i = 1
+                       while uvname in uvnames:
+                               uvname = '%s.%03d' % (uvname_org, i)
+                               i+=1
+                       
+                       me.addUVLayer(uvname)
+                       me.activeUVLayer = uvname
+                       
+                       del uvnames, uvname_org, uvname
        
        for face_sel in face_groups:
                print "\nStarting unwrap"
@@ -402,11 +417,14 @@ PREF_MARGIN_DIV=          512):
                # ...limiting this is needed or you end up with bug unused texture spaces
                # ...however if its too high, boxpacking is way too slow for high poly meshes.
                float_to_int_factor = lengths_to_ints[0][0]
-               max_int_dimension = int(((side_len / float_to_int_factor)) / PREF_BOX_DIV)
-               
+               if float_to_int_factor > 0:
+                       max_int_dimension = int(((side_len / float_to_int_factor)) / PREF_BOX_DIV)
+                       ok = True
+               else:
+                       max_int_dimension = 0.0 # wont be used
+                       ok = False
                
                # RECURSIVE prettyface grouping
-               ok = True
                while ok:
                        ok = False
                        
index c4e504a5bff3c32ba0b831067c3f60d8a8399c2d..338075c1b18e64bd6fa7e1b333d07b11edc99b69 100644 (file)
@@ -32,7 +32,7 @@ Name "Blender VERSION"
     
 !insertmacro MUI_PAGE_DIRECTORY
 Page custom DataLocation DataLocationOnLeave
-Page custom AppDataChoice AppDataChoiceOnLeave
+;Page custom AppDataChoice AppDataChoiceOnLeave
 Page custom PreMigrateUserSettings MigrateUserSettings
 !insertmacro MUI_PAGE_INSTFILES
 !insertmacro MUI_PAGE_FINISH
@@ -271,7 +271,9 @@ Function DataLocationOnLeave
        StrCpy $SETUSERCONTEXT "false"
        ${NSD_GetState} $HWND_APPDATA $R0
        ${If} $R0 == "1"
-         StrCpy $SETUSERCONTEXT "true"
+         ; FIXME: disabled 'all users' until fully multi-user compatible
+         ;StrCpy $SETUSERCONTEXT "true"
+         Call SetWinXPPathCurrentUser
        ${Else}
          ${NSD_GetState} $HWND_INSTDIR $R0
          ${If} $R0 == "1"
index 604446750471d8122d0007df4301314a2beab2d9..45d8193b16fd9d21b56a21c079b3f87b657e6400 100644 (file)
@@ -39,8 +39,8 @@ struct ListBase;
 struct BezTriple;
 struct BevList;
 
-#define KNOTSU(nu)         ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-#define KNOTSV(nu)         ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
+#define KNOTSU(nu)         ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & CU_CYCLIC) )
+#define KNOTSV(nu)         ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & CU_CYCLIC) )
 
 
 void unlink_curve( struct Curve *cu);
@@ -84,5 +84,12 @@ void switchdirectionNurb( struct Nurb *nu);
 float (*curve_getVertexCos(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
 void curve_applyVertexCos(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
 
+/* nurb checks if they can be drawn, also clamp order func */
+int check_valid_nurb_u( struct Nurb *nu);
+int check_valid_nurb_v( struct Nurb *nu);
+
+int clamp_nurb_order_u( struct Nurb *nu);
+int clamp_nurb_order_v( struct Nurb *nu);
+
 #endif
 
index d02a7c0ab9e617c4f9ba255f70219f16fdef9e9d..396bdda9c10528b7013b1b9a16aadcab9c1b1b7c 100644 (file)
@@ -348,9 +348,9 @@ void freeNurb(Nurb *nu)
        if(nu->bp) MEM_freeN(nu->bp);
        nu->bp= 0;
        if(nu->knotsu) MEM_freeN(nu->knotsu);
-       nu->knotsu= 0;
+       nu->knotsu= NULL;
        if(nu->knotsv) MEM_freeN(nu->knotsv);
-       nu->knotsv= 0;
+       nu->knotsv= NULL;
        /* if(nu->trim.first) freeNurblist(&(nu->trim)); */
 
        MEM_freeN(nu);
@@ -393,7 +393,7 @@ Nurb *duplicateNurb(Nurb *nu)
                        (BPoint*)MEM_mallocN((len)* sizeof(BPoint),"duplicateNurb3");
                memcpy(newnu->bp, nu->bp, len*sizeof(BPoint));
                
-               newnu->knotsu=newnu->knotsv= 0;
+               newnu->knotsu= newnu->knotsv= NULL;
                
                if(nu->knotsu) {
                        len= KNOTSU(nu);
@@ -506,6 +506,7 @@ static void calcknots(float *knots, short aantal, short order, short type)
                }
        }
        else if(type==2) {
+               /* Warning, the order MUST be 2 or 4, if this is not enforced, the displist will be corrupt */
                if(order==4) {
                        k= 0.34;
                        for(a=0;a<t;a++) {
@@ -520,6 +521,9 @@ static void calcknots(float *knots, short aantal, short order, short type)
                                knots[a]= (float)floor(k);
                        }
                }
+               else {
+                       printf("bez nurb curve order is not 3 or 4, should never happen\n");
+               }
        }
 }
 
@@ -529,7 +533,8 @@ static void makecyclicknots(float *knots, short pnts, short order)
        int a, b, order2, c;
 
        if(knots==0) return;
-        order2=order-1;
+
+       order2=order-1;
 
        /* do first long rows (order -1), remove identical knots at endpoints */
        if(order>2) {
@@ -549,26 +554,35 @@ static void makecyclicknots(float *knots, short pnts, short order)
 }
 
 
-void makeknots(Nurb *nu, short uv, short type) /* 0: uniform, 1: endpoints, 2: bezier */
+/* type - 0: uniform, 1: endpoints, 2: bezier, note, cyclic nurbs are always uniform */
+void makeknots(Nurb *nu, short uv, short type)
 {
        if( (nu->type & 7)==CU_NURBS ) {
-               if(uv & 1) {
+               if(uv == 1) {
                        if(nu->knotsu) MEM_freeN(nu->knotsu);
-                       if(nu->pntsu>1) {
+                       if(check_valid_nurb_u(nu)) {
                                nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots");
-                               calcknots(nu->knotsu, nu->pntsu, nu->orderu, type);
-                               if(nu->flagu & 1) makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu);
+                               if(nu->flagu & CU_CYCLIC) {
+                                       calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0);  /* cyclic should be uniform */
+                                       makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu);
+                               } else {
+                                       calcknots(nu->knotsu, nu->pntsu, nu->orderu, type);
+                               }
                        }
-                       else nu->knotsu= 0;
-               }
-               if(uv & 2) {
+                       else nu->knotsu= NULL;
+               
+               } else if(uv == 2) {
                        if(nu->knotsv) MEM_freeN(nu->knotsv);
-                       if(nu->pntsv>1) {
+                       if(check_valid_nurb_v(nu)) {
                                nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots");
-                               calcknots(nu->knotsv, nu->pntsv, nu->orderv, type);
-                               if(nu->flagv & 1) makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv);
+                               if(nu->flagv & CU_CYCLIC) {
+                                       calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0);  /* cyclic should be uniform */
+                                       makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv);
+                               } else {
+                                       calcknots(nu->knotsv, nu->pntsv, nu->orderv, type);
+                               }
                        }
-                       else nu->knotsv= 0;
+                       else nu->knotsv= NULL;
                }
        }
 }
@@ -645,7 +659,7 @@ void makeNurbfaces(Nurb *nu, float *data, int rowstride)
        int i, j, iofs, jofs, cycl, len, resolu, resolv;
        int istart, iend, jsta, jen, *jstart, *jend, ratcomp;
 
-       if(nu->knotsu==0 || nu->knotsv==0) return;
+       if(nu->knotsu==NULL || nu->knotsv==NULL) return;
        if(nu->orderu>nu->pntsu) return;
        if(nu->orderv>nu->pntsv) return;
        if(data==0) return;
@@ -679,24 +693,24 @@ void makeNurbfaces(Nurb *nu, float *data, int rowstride)
 
        fp= nu->knotsu;
        ustart= fp[nu->orderu-1];
-       if(nu->flagu & 1) uend= fp[nu->pntsu+nu->orderu-1];
+       if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
        else uend= fp[nu->pntsu];
-       ustep= (uend-ustart)/(resolu-1+(nu->flagu & 1));
+       ustep= (uend-ustart)/(resolu-1+(nu->flagu & CU_CYCLIC));
        basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbfaces3");
 
        fp= nu->knotsv;
        vstart= fp[nu->orderv-1];
        
-       if(nu->flagv & 1) vend= fp[nu->pntsv+nu->orderv-1];
+       if(nu->flagv & CU_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1];
        else vend= fp[nu->pntsv];
-       vstep= (vend-vstart)/(resolv-1+(nu->flagv & 1));
+       vstep= (vend-vstart)/(resolv-1+(nu->flagv & CU_CYCLIC));
        len= KNOTSV(nu);
        basisv= (float *)MEM_mallocN(sizeof(float)*len*resolv, "makeNurbfaces3");
        jstart= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces4");
        jend= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces5");
 
        /* precalculation of basisv and jstart,jend */
-       if(nu->flagv & 1) cycl= nu->orderv-1; 
+       if(nu->flagv & CU_CYCLIC) cycl= nu->orderv-1; 
        else cycl= 0;
        v= vstart;
        basis= basisv;
@@ -706,7 +720,7 @@ void makeNurbfaces(Nurb *nu, float *data, int rowstride)
                v+= vstep;
        }
 
-       if(nu->flagu & 1) cycl= nu->orderu-1; 
+       if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1; 
        else cycl= 0;
        in= data;
        u= ustart;
@@ -803,7 +817,7 @@ void makeNurbcurve(Nurb *nu, float *data, int resolu, int dim)
        float *basisu, *sum, *fp,  *in;
        int i, len, istart, iend, cycl;
 
-       if(nu->knotsu==0) return;
+       if(nu->knotsu==NULL) return;
        if(nu->orderu>nu->pntsu) return;
        if(data==0) return;
 
@@ -820,12 +834,12 @@ void makeNurbcurve(Nurb *nu, float *data, int resolu, int dim)
 
        fp= nu->knotsu;
        ustart= fp[nu->orderu-1];
-       if(nu->flagu & 1) uend= fp[nu->pntsu+nu->orderu-1];
+       if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
        else uend= fp[nu->pntsu];
-       ustep= (uend-ustart)/(resolu-1+(nu->flagu & 1));
+       ustep= (uend-ustart)/(resolu-1+(nu->flagu & CU_CYCLIC));
        basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3");
 
-       if(nu->flagu & 1) cycl= nu->orderu-1; 
+       if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1; 
        else cycl= 0;
 
        in= data;
@@ -1425,14 +1439,14 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
        
        /* returns a point */
        if(prevbezt==nu->bezt) {
-               if(nu->flagu & 1) pprev= last;
+               if(nu->flagu & CU_CYCLIC) pprev= last;
                else pprev= prevbezt;
        }
        else pprev= prevbezt-1;
        
        /* next point */
        if(bezt==last) {
-               if(nu->flagu & 1) next= nu->bezt;
+               if(nu->flagu & CU_CYCLIC) next= nu->bezt;
                else next= bezt;
        }
        else next= bezt+1;
@@ -1478,7 +1492,7 @@ void makeBevelList(Object *ob)
        while(nu) {
                /* check we are a single point? also check we are not a surface and that the orderu is sane,
                 * enforced in the UI but can go wrong possibly */
-               if(nu->pntsu<2 || ((nu->type & 7)==CU_NURBS && nu->pntsu < nu->orderu)) {
+               if(!check_valid_nurb_u(nu)) {
                        bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList");
                        BLI_addtail(&(cu->bev), bl);
                        bl->nr= 0;
@@ -1493,7 +1507,7 @@ void makeBevelList(Object *ob)
                                bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
                                BLI_addtail(&(cu->bev), bl);
        
-                               if(nu->flagu & 1) bl->poly= 0;
+                               if(nu->flagu & CU_CYCLIC) bl->poly= 0;
                                else bl->poly= -1;
                                bl->nr= len;
                                bl->flag= 0;
@@ -1512,17 +1526,17 @@ void makeBevelList(Object *ob)
                        }
                        else if((nu->type & 7)==CU_BEZIER) {
        
-                               len= resolu*(nu->pntsu+ (nu->flagu & 1) -1)+1;  /* in case last point is not cyclic */
+                               len= resolu*(nu->pntsu+ (nu->flagu & CU_CYCLIC) -1)+1;  /* in case last point is not cyclic */
                                bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
                                BLI_addtail(&(cu->bev), bl);
        
-                               if(nu->flagu & 1) bl->poly= 0;
+                               if(nu->flagu & CU_CYCLIC) bl->poly= 0;
                                else bl->poly= -1;
                                bevp= (BevPoint *)(bl+1);
        
                                a= nu->pntsu-1;
                                bezt= nu->bezt;
-                               if(nu->flagu & 1) {
+                               if(nu->flagu & CU_CYCLIC) {
                                        a++;
                                        prevbezt= nu->bezt+(nu->pntsu-1);
                                }
@@ -1595,7 +1609,7 @@ void makeBevelList(Object *ob)
                                MEM_freeN(data);
                                MEM_freeN(data_a);
                                
-                               if((nu->flagu & 1)==0) {            /* not cyclic: endpoint */
+                               if((nu->flagu & CU_CYCLIC)==0) {            /* not cyclic: endpoint */
                                        bevp->x= prevbezt->vec[1][0];
                                        bevp->y= prevbezt->vec[1][1];
                                        bevp->z= prevbezt->vec[1][2];
@@ -1611,7 +1625,7 @@ void makeBevelList(Object *ob)
                                        BLI_addtail(&(cu->bev), bl);
                                        bl->nr= len;
                                        bl->flag= 0;
-                                       if(nu->flagu & 1) bl->poly= 0;
+                                       if(nu->flagu & CU_CYCLIC) bl->poly= 0;
                                        else bl->poly= -1;
                                        bevp= (BevPoint *)(bl+1);
        
@@ -2209,7 +2223,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
        
        a= nu->pntsu;
        bezt= nu->bezt;
-       if(nu->flagu & 1) prev= bezt+(a-1);
+       if(nu->flagu & CU_CYCLIC) prev= bezt+(a-1);
        else prev= 0;
        next= bezt+1;
 
@@ -2217,7 +2231,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
                calchandleNurb(bezt, prev, next, 0);
                prev= bezt;
                if(a==1) {
-                       if(nu->flagu & 1) next= nu->bezt;
+                       if(nu->flagu & CU_CYCLIC) next= nu->bezt;
                        else next= 0;
                }
                else next++;
@@ -2608,3 +2622,63 @@ void curve_applyVertexCos(Curve *cu, ListBase *lb, float (*vertexCos)[3])
                }
        }
 }
+
+int check_valid_nurb_u( struct Nurb *nu )
+{
+       if (nu==NULL)                                           return 0;
+       if (nu->pntsu <= 1)                                     return 0;
+       if ((nu->type & 7)!=CU_NURBS)           return 1; /* not a nurb, lets assume its valid */
+       
+       if (nu->pntsu < nu->orderu)                     return 0;
+       if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagu>>1) & 2)) { /* Bezier U Endpoints */
+               if (nu->orderu==4) {
+                       if (nu->pntsu < 5)                      return 0; /* bezier with 4 orderu needs 5 points */
+               } else if (nu->orderu != 3)             return 0; /* order must be 3 or 4 */
+       }
+       return 1;
+}
+int check_valid_nurb_v( struct Nurb *nu)
+{
+       if (nu==NULL)                                           return 0;
+       if (nu->pntsv <= 1)                                     return 0;
+       if ((nu->type & 7)!=CU_NURBS)           return 1; /* not a nurb, lets assume its valid */
+       
+       if (nu->pntsv < nu->orderv)                     return 0;
+       if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagv>>1) & 2)) { /* Bezier V Endpoints */
+               if (nu->orderv==4) {
+                       if (nu->pntsv < 5)                      return 0; /* bezier with 4 orderu needs 5 points */
+               } else if (nu->orderv != 3)             return 0; /* order must be 3 or 4 */
+       }
+       return 1;
+}
+
+int clamp_nurb_order_u( struct Nurb *nu )
+{
+       int change = 0;
+       if(nu->pntsu<nu->orderu) {
+               nu->orderu= nu->pntsu;
+               change= 1;
+       }
+       if(((nu->flag & CU_CYCLIC)==0) && (nu->flagu>>1)&2) {
+               CLAMP(nu->orderu, 3,4);
+               change= 1;
+       }
+       return change;
+}
+
+int clamp_nurb_order_v( struct Nurb *nu)
+{
+       int change = 0;
+       if(nu->pntsv<nu->orderv) {
+               nu->orderv= nu->pntsv;
+               change= 1;
+       }
+       if(((nu->flag & CU_CYCLIC)==0) && (nu->flagv>>1)&2) {
+               CLAMP(nu->orderv, 3,4);
+               change= 1;
+       }
+       return change;
+}
+
+
+
index aa43644105688601834530d7b52bfcd0443d6fcc..298e4b81d5bae9b9f4742f914967151f530a0427 100644 (file)
@@ -783,7 +783,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
                        else
                                resolu= nu->resolu;
                        
-                       if(nu->pntsu<2 || ((nu->type & 7)==CU_NURBS && nu->pntsu < nu->orderu));
+                       if(!check_valid_nurb_u(nu));
                        else if((nu->type & 7)==CU_BEZIER) {
                                
                                /* count */
@@ -816,7 +816,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
 
                                data= dl->verts;
 
-                               if(nu->flagu & 1) {
+                               if(nu->flagu & CU_CYCLIC) {
                                        dl->type= DL_POLY;
                                        a= nu->pntsu;
                                }
@@ -863,7 +863,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
                                dl->charidx = nu->charidx;
 
                                data= dl->verts;
-                               if(nu->flagu & 1) dl->type= DL_POLY;
+                               if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
                                else dl->type= DL_SEGM;
                                makeNurbcurve(nu, data, resolu, 3);
                        }
@@ -878,7 +878,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
                                dl->charidx = nu->charidx;
 
                                data= dl->verts;
-                               if(nu->flagu & 1) dl->type= DL_POLY;
+                               if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
                                else dl->type= DL_SEGM;
                                
                                a= len;
@@ -1330,7 +1330,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
                                dl->rt= nu->flag;
                                
                                data= dl->verts;
-                               if(nu->flagu & 1) dl->type= DL_POLY;
+                               if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
                                else dl->type= DL_SEGM;
                                
                                makeNurbcurve(nu, data, nu->resolu, 3);
index 09c939629903d40cdb44036c229910dd346cfe41..52275e507dde916be38794beef77814408a613c6 100644 (file)
@@ -440,7 +440,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
        if (nu2 == NULL) return;
        nu2->resolu= cu->resolu;
        nu2->bezt = NULL;
-       nu2->knotsu = nu2->knotsv = 0;
+       nu2->knotsu = nu2->knotsv = NULL;
        nu2->flag= 0;
        nu2->charidx = charidx+1000;
        if (mat_nr > 0) nu2->mat_nr= mat_nr-1;
@@ -529,7 +529,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
                        memcpy(nu2, nu1, sizeof(struct Nurb));
                        nu2->resolu= cu->resolu;
                        nu2->bp = 0;
-                       nu2->knotsu = nu2->knotsv = 0;
+                       nu2->knotsu = nu2->knotsv = NULL;
                        nu2->flag= CU_SMOOTH;
                        nu2->charidx = charidx;
                        if (info->mat_nr) {
index 3b1b01758ed12607f3c49c026a77dcb74fa1bd10..73005f3708e3235f2fca4ac09b031929242216ee 100644 (file)
@@ -6486,12 +6486,14 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
        MFace *mf=0;
        MVert *dupvert=0;
        ParticleSettings *part=psmd->psys->part;
-       ParticleData *pa, *pars=psmd->psys->particles;
+       ParticleData *pa=NULL, *pars=psmd->psys->particles;
        ParticleKey state;
+       EdgeHash *vertpahash;
+       EdgeHashIterator *ehi;
        float *vertco=0, imat[4][4];
        float loc0[3], nor[3];
        float timestep, cfra;
-       int *facepa=emd->facepa, *vertpa=0;
+       int *facepa=emd->facepa;
        int totdup=0,totvert=0,totface=0,totpart=0;
        int i, j, v, mindex=0;
 
@@ -6506,34 +6508,36 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
        else
                cfra=bsystem_time(ob,(float)G.scene->r.cfra,0.0);
 
-       /* table for vertice <-> particle relations (row totpart+1 is for yet unexploded verts) */
-       vertpa = MEM_callocN(sizeof(int)*(totpart+1)*totvert, "explode_vertpatab");
-       for(i=0; i<(totpart+1)*totvert; i++)
-               vertpa[i] = -1;
+       /* hash table for vertice <-> particle relations */
+       vertpahash= BLI_edgehash_new();
 
        for (i=0; i<totface; i++) {
+               /* do mindex + totvert to ensure the vertex index to be the first
+                * with BLI_edgehashIterator_getKey */
                if(facepa[i]==totpart || cfra <= (pars+facepa[i])->time)
-                       mindex = totpart*totvert;
+                       mindex = totvert+totpart;
                else 
-                       mindex = facepa[i]*totvert;
+                       mindex = totvert+facepa[i];
 
                mf=CDDM_get_face(dm,i);
 
-               /*set face vertices to exist in particle group*/
-               vertpa[mindex+mf->v1] = 1;
-               vertpa[mindex+mf->v2] = 1;
-               vertpa[mindex+mf->v3] = 1;
+               /* set face vertices to exist in particle group */
+               BLI_edgehash_insert(vertpahash, mf->v1, mindex, NULL);
+               BLI_edgehash_insert(vertpahash, mf->v2, mindex, NULL);
+               BLI_edgehash_insert(vertpahash, mf->v3, mindex, NULL);
                if(mf->v4)
-                       vertpa[mindex+mf->v4] = 1;
+                       BLI_edgehash_insert(vertpahash, mf->v4, mindex, NULL);
        }
 
-       /*make new vertice indexes & count total vertices after duplication*/
-       for(i=0; i<(totpart+1)*totvert; i++){
-               if(vertpa[i] != -1)
-                       vertpa[i] = totdup++;
+       /* make new vertice indexes & count total vertices after duplication */
+       ehi= BLI_edgehashIterator_new(vertpahash);
+       for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
+               BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totdup));
+               totdup++;
        }
+       BLI_edgehashIterator_free(ehi);
 
-       /*the final duplicated vertices*/
+       /* the final duplicated vertices */
        explode= CDDM_from_template(dm, totdup, 0,totface);
        dupvert= CDDM_get_verts(explode);
 
@@ -6542,45 +6546,49 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
 
        psmd->psys->lattice = psys_get_lattice(ob, psmd->psys);
 
-       /*duplicate & displace vertices*/
-       for(i=0, pa=pars; i<=totpart; i++, pa++){
-               if(i!=totpart){
+       /* duplicate & displace vertices */
+       ehi= BLI_edgehashIterator_new(vertpahash);
+       for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
+               MVert source;
+               MVert *dest;
+
+               /* get particle + vertex from hash */
+               BLI_edgehashIterator_getKey(ehi, &j, &i);
+               i -= totvert;
+               v= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
+
+               dm->getVert(dm, j, &source);
+               dest = CDDM_get_vert(explode,v);
+
+               DM_copy_vert_data(dm,explode,j,v,1);
+               *dest = source;
+
+               if(i!=totpart) {
+                       /* get particle */
+                       pa= pars+i;
+
+                       /* get particle state */
                        psys_particle_on_emitter(ob, psmd,part->from,pa->num,-1,pa->fuv,pa->foffset,loc0,nor,0,0,0,0);
                        Mat4MulVecfl(ob->obmat,loc0);
 
                        state.time=cfra;
                        psys_get_particle_state(ob,psmd->psys,i,&state,1);
-               }
-
-               for(j=0; j<totvert; j++){
-                       v=vertpa[i*totvert+j];
-                       if(v != -1) {
-                               MVert source;
-                               MVert *dest;
-
-                               dm->getVert(dm, j, &source);
-                               dest = CDDM_get_vert(explode,v);
-
-                               DM_copy_vert_data(dm,explode,j,v,1);
-                               *dest = source;
 
-                               if(i!=totpart){
-                                       vertco=CDDM_get_vert(explode,v)->co;
-                                       
-                                       Mat4MulVecfl(ob->obmat,vertco);
+                       vertco=CDDM_get_vert(explode,v)->co;
+                       
+                       Mat4MulVecfl(ob->obmat,vertco);
 
-                                       VECSUB(vertco,vertco,loc0);
+                       VECSUB(vertco,vertco,loc0);
 
-                                       /* apply rotation, size & location */
-                                       QuatMulVecf(state.rot,vertco);
-                                       VecMulf(vertco,pa->size);
-                                       VECADD(vertco,vertco,state.co);
+                       /* apply rotation, size & location */
+                       QuatMulVecf(state.rot,vertco);
+                       VecMulf(vertco,pa->size);
+                       VECADD(vertco,vertco,state.co);
 
-                                       Mat4MulVecfl(imat,vertco);
-                               }
-                       }
+                       Mat4MulVecfl(imat,vertco);
                }
        }
+       BLI_edgehashIterator_free(ehi);
 
        /*map new vertices to faces*/
        for (i=0; i<totface; i++) {
@@ -6602,15 +6610,15 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
                orig_v4 = source.v4;
 
                if(facepa[i]!=totpart && cfra <= pa->time)
-                       mindex = totpart*totvert;
+                       mindex = totvert+totpart;
                else 
-                       mindex = facepa[i]*totvert;
+                       mindex = totvert+facepa[i];
 
-               source.v1 = vertpa[mindex+source.v1];
-               source.v2 = vertpa[mindex+source.v2];
-               source.v3 = vertpa[mindex+source.v3];
+               source.v1 = edgesplit_get(vertpahash, source.v1, mindex);
+               source.v2 = edgesplit_get(vertpahash, source.v2, mindex);
+               source.v3 = edgesplit_get(vertpahash, source.v3, mindex);
                if(source.v4)
-                       source.v4 = vertpa[mindex+source.v4];
+                       source.v4 = edgesplit_get(vertpahash, source.v4, mindex);
 
                DM_copy_face_data(dm,explode,i,i,1);
 
@@ -6619,9 +6627,10 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
                test_index_face(mf, &explode->faceData, i, (mf->v4 ? 4 : 3));
        }
 
+       MEM_printmemlist_stats();
 
        /* cleanup */
-       if(vertpa) MEM_freeN(vertpa);
+       BLI_edgehash_free(vertpahash, NULL);
 
        /* finalization */
        CDDM_calc_edges(explode);
index ab1bc5a2265be412d4ebea2c5fc2f0ea4ad2d9ed..4f901ba72163c688b84a243211260a29e657bebc 100644 (file)
@@ -1614,7 +1614,7 @@ static void give_parvert(Object *par, int nr, float *vec)
                        
                        for(eve= em->verts.first; eve; eve= eve->next) {
                                if(eve->keyindex==nr) {
-                                       memcpy(vec, eve->co, 12);
+                                       memcpy(vec, eve->co, sizeof(float)*3);
                                        break;
                                }
                        }
@@ -1652,18 +1652,20 @@ static void give_parvert(Object *par, int nr, float *vec)
                Curve *cu;
                BPoint *bp;
                BezTriple *bezt;
+               int found= 0;
                
                cu= par->data;
                nu= cu->nurb.first;
                if(par==G.obedit) nu= editNurb.first;
                
                count= 0;
-               while(nu) {
+               while(nu && !found) {
                        if((nu->type & 7)==CU_BEZIER) {
                                bezt= nu->bezt;
                                a= nu->pntsu;
                                while(a--) {
                                        if(count==nr) {
+                                               found= 1;
                                                VECCOPY(vec, bezt->vec[1]);
                                                break;
                                        }
@@ -1676,7 +1678,8 @@ static void give_parvert(Object *par, int nr, float *vec)
                                a= nu->pntsu*nu->pntsv;
                                while(a--) {
                                        if(count==nr) {
-                                               memcpy(vec, bp->vec, 12);
+                                               found= 1;
+                                               memcpy(vec, bp->vec, sizeof(float)*3);
                                                break;
                                        }
                                        count++;
index 464f97d294d0b359850d3be0da39e7b83f03c1cf..8b979f9ed2330f6e6a012d0e9bf922077925c313 100644 (file)
@@ -150,7 +150,7 @@ void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd)
                        nu->type= CU_BEZIER+CU_2D;
                        nu->pntsu = onpoints[j];
                        nu->resolu= 8;
-                       nu->flagu= 1;
+                       nu->flagu= CU_CYCLIC;
                        nu->bezt = bezt;
 
                        //individual curve loop, start-end
index 8cdc0601c7e5ed5da3aa8409c52ff8f43addc68b..498c87cdef96dc5df563192945d24e271586345e 100644 (file)
@@ -2017,7 +2017,7 @@ static VFontData *objfnt_to_vfontdata(objfnt *fnt)
                                                nu->type= CU_BEZIER+CU_2D;
                                                nu->pntsu = count;
                                                nu->resolu= 8;
-                                               nu->flagu= 1;
+                                               nu->flagu= CU_CYCLIC;
                                                nu->bezt = bezt;
                                                stop = 0;
 
index c85849b5ed4be35af35c35c406011801e8ef005f..3610813f2dac1be4c7023eee39356e772bee759b 100644 (file)
@@ -1166,6 +1166,7 @@ int BLI_convertstringcode(char *path, const char *basepath)
                MEM_freeN(filepart);
        }
        
+       BLI_cleanup_file(NULL, tmp);
        strcpy(path, tmp);
        
 #ifdef WIN32
index 9e25550ce04410b173216bd36ae7a20c4b314101..4604359fcc92d62e0ffe8cfdb6716cfa7ef5142b 100644 (file)
@@ -37,6 +37,9 @@ struct BezTriple;
 struct BPoint;
 struct BezTripleNurb;
 
+void set_actNurb(struct Nurb *nu);
+struct Nurb * get_actNurb( void );
+
 short isNurbsel(struct Nurb *nu);
 int isNurbsel_count(struct Nurb *nu);
 void printknots(void);
index 982a2f25df700c8d5ea131fe2e54b828365ae7c2..82adb1ac12af8ee302aac102034bf2f7739d0478 100644 (file)
@@ -515,6 +515,7 @@ int handleNDofInput(NDofInput *n, unsigned short event, short val);
 
 int manageObjectSpace(int confirm, int set);
 int manageMeshSpace(int confirm, int set);
+int manageBoneSpace(int confirm, int set);
 
 /* Those two fill in mat and return non-zero on success */
 int createSpaceNormal(float mat[3][3], float normal[3]);
index 9b837f9f9886b013c393617c14f44eab892048ca..83f4e633fa1670303de53f430d3ebbe1e1eb7e18 100644 (file)
@@ -688,18 +688,18 @@ static int calculate_structlens(int firststruct)
                                                /* 4-8 aligned/ */
                                                if(sizeof(void *) == 4) {
                                                        if (len % 4) {
-                                                               printf("Align pointer error in struct: %s %s\n", types[structtype], cp);
+                                                               printf("Align pointer error in struct (len4): %s %s\n", types[structtype], cp);
                                                                dna_error = 1;
                                                        }
                                                } else {
                                                        if (len % 8) {
-                                                               printf("Align pointer error in struct: %s %s\n", types[structtype], cp);
+                                                               printf("Align pointer error in struct (len8): %s %s\n", types[structtype], cp);
                                                                dna_error = 1;
                                                        }
                                                }
 
                                                if (alphalen % 8) {
-                                                       printf("Align pointer error in struct: %s %s\n", types[structtype],cp);
+                                                       printf("Align pointer error in struct (alphalen8): %s %s\n", types[structtype],cp);
                                                        dna_error = 1;
                                                }
 
@@ -748,13 +748,13 @@ static int calculate_structlens(int firststruct)
                                        // has_pointer is set or alphalen != len
                                        if (has_pointer || alphalen != len) {
                                                if (alphalen % 8) {
-                                                       printf("Sizeerror in struct: %s (add %d bytes)\n", types[structtype], alphalen%8);
+                                                       printf("Sizeerror in struct: %s (add %d bytes)\n", types[structtype], alphalen%8);
                                                        dna_error = 1;
                                                }
                                        }
                                        
                                        if(len % 4) {
-                                               printf("Sizeerror in struct: %s (add %d bytes)\n", types[structtype], len%4);
+                                               printf("Sizeerror in struct: %s (add %d bytes)\n", types[structtype], len%4);
                                                dna_error = 1;
                                        }
                                        
index 12b3616df256594049c27b18d5f0ff5a6270d4bd..7cf2411ed84b11aa800331e2eaf6871e4f361817 100644 (file)
@@ -35,8 +35,6 @@ include nan_compile.mk
 
 CFLAGS += $(LEVEL_1_C_WARNINGS)
 
-CPPFLAGS +=  -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I../../python
 CPPFLAGS += -I../../blenkernel
 CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
 CPPFLAGS += -I../../makesdna
index cd7ec781b2bd9b14340ef11f4293c4d1f4b26c69..3d4546613be47d74481bba65f76ce8a29d472e6c 100644 (file)
@@ -2063,22 +2063,22 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
        /*GLfloat scissorBox[4];*/
 
        /* parse the arguments passed-in from Python */
-       if( !PyArg_ParseTuple( args, "Off|ffiiii", &pyObjImage, 
+       if( !PyArg_ParseTuple( args, "O!ff|ffiiii", &Image_Type, &pyObjImage, 
                &originX, &originY, &zoomX, &zoomY, 
                &clipX, &clipY, &clipW, &clipH ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
                        "expected a Blender.Image and 2 floats, and " \
                        "optionally 2 floats and 4 ints as arguments" );
-       /* check that the first PyObject is actually a Blender.Image */
-       if( !BPy_Image_Check( pyObjImage ) )
-               return EXPP_ReturnPyObjError( PyExc_TypeError,
-                       "expected a Blender.Image and 2 floats, and " \
-                       "optionally 2 floats and 4 ints as arguments" );
        /* check that the zoom factors are valid */
-       if( ( zoomX <= 0.0 ) || ( zoomY <= 0.0 ) )
+       if( ( zoomX < 0.0 ) || ( zoomY < 0.0 ) )
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                       "invalid zoom factors - they must be >= 0.0" );
-
+                       "invalid zoom factors - they must be > 0.0" );
+       if ((zoomX == 0.0 ) || ( zoomY == 0.0 )) {
+               /* sometimes python doubles can be converted from small values to a zero float, in this case just dont draw */
+               Py_RETURN_NONE;
+       }
+       
+       
        /* fetch a C Image pointer from the passed-in Python object */
        py_img = ( BPy_Image * ) pyObjImage;
        image = py_img->image;
@@ -2101,9 +2101,9 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
         * the image as they can. */
        clipX = EXPP_ClampInt( clipX, 0, ibuf->x );
        clipY = EXPP_ClampInt( clipY, 0, ibuf->y );
-       if( ( clipW < 0 ) || ( clipW > ( ibuf->x - clipW ) ) )
+       if( ( clipW < 0 ) || ( clipX+clipW > ibuf->x ) )
                clipW = ibuf->x - clipX;
-       if( ( clipH < 0 ) || ( clipH > ( ibuf->y - clipH ) ) )
+       if( ( clipH < 0 ) || ( clipY+clipH > ibuf->y ) )
                clipH = ibuf->y - clipY;
 
        /* -- we are "Go" to Draw! -- */
@@ -2165,8 +2165,7 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
        glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
        glPixelStorei( GL_UNPACK_ROW_LENGTH,  0 );
 
-       Py_INCREF( Py_None );
-       return Py_None;
+       Py_RETURN_NONE;
 
 }
 
index 92529023b7e44afeb186027dbb3489f5585cf307..792b23315084c5ea648733f84782d1c9b8bbf943 100644 (file)
@@ -848,7 +848,7 @@ static int Sockoutmap_assign_subscript(BPy_SockMap *self, PyObject *pyidx, PyObj
 
        if (PyInt_Check(pyidx)) {
                idx = (int)PyInt_AsLong(pyidx);
-               if (idx < 0 || idx >= Sockinmap_len(self))
+               if (idx < 0 || idx >= Sockoutmap_len(self))
                        return EXPP_ReturnIntError(PyExc_IndexError, "index out of range");
        }
        else if (PyString_Check(pyidx)) {
index 82f99adcdb1ee9ab76fdfd6bd75782d49136880d..1a806932bdba9252b53ad2bd84ba061c53ced0e4 100644 (file)
@@ -341,6 +341,7 @@ static int setupPI(Object* ob);
 
 static PyObject *Object_getParticleSys( BPy_Object * self );
 /* fixme Object_newParticleSys( self, default-partsys-name ) */
+static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args);
 static PyObject *Object_newParticleSys( BPy_Object * self );
 static PyObject *Object_buildParts( BPy_Object * self );
 static PyObject *Object_clearIpo( BPy_Object * self );
@@ -475,6 +476,8 @@ static PyMethodDef BPy_Object_methods[] = {
         "Return a list of particle systems"},
        {"newParticleSystem", ( PyCFunction ) Object_newParticleSys, METH_NOARGS,
         "Create and link a new particle system"},
+       {"addVertexGroupsFromArmature" , ( PyCFunction ) Object_addVertexGroupsFromArmature, METH_VARARGS,
+        "Add vertex groups from armature using the bone heat method"},
        {"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS,
         "Recalcs particle system (if any), (depricated, will always return an empty list in version 2.46)"},
        {"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS,
@@ -1109,6 +1112,42 @@ PyObject *Object_newParticleSys( BPy_Object * self ){
        return ParticleSys_CreatePyObject(rpsys,ob);
 }
 
+/*****************************************************************************/
+/* attribute:           addVertexGroupsFromArmature                          */
+/* Description:         evaluate and add vertex groups to the current object */
+/*                      for each bone of the selected armature               */   
+/* Data:                self Object, Bpy armature                            */
+/* Return:              nothing                                              */
+/*****************************************************************************/
+static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args)
+{
+       
+       Object *ob = self->object;
+       BPy_Object *arm;
+
+       if( ob->type != OB_MESH )
+               return EXPP_ReturnPyObjError( PyExc_TypeError,
+                               "Only useable on Mesh type Objects" );
+       
+       if( G.obedit != NULL)
+               return EXPP_ReturnPyObjError( PyExc_TypeError,
+                               "Not useable when inside edit mode" );
+       
+       /* Check if the arguments passed to makeParent are valid. */
+       if( !PyArg_ParseTuple( args, "O!",&Object_Type, &arm ) )
+               return EXPP_ReturnPyObjError( PyExc_TypeError,
+                               "An armature object is expected." );
+       
+       if( arm->object->type != OB_ARMATURE ) 
+               return EXPP_ReturnPyObjError( PyExc_TypeError,
+                               "An armature object is expected." );
+                       
+       add_verts_to_dgroups(ob, arm->object, 1, 0);
+       ob->recalc |= OB_RECALC_OB;  
+       
+       Py_RETURN_NONE;
+}
+
 static PyObject *Object_buildParts( BPy_Object * self )
 {
        /* This is now handles by modifiers */
index 15307cc2be580c770cd94a6e04059f9af3729ad4..f0a32db0623e446b02b435ed109bd09123945a78 100644 (file)
@@ -828,7 +828,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
                /* little hack to calculate hair steps in render mode */
                psys->renderdata = (void*)(int)1;
 
-               psys_cache_paths(ob, psys, cfra, 0);
+               psys_cache_paths(ob, psys, cfra, 1);
 
                psys->renderdata = NULL;
 
index 7ef351b112751349d96ba610ceb716c927829ae2..eba951b88133b434ce0946e226fba18ae65ea9bb 100644 (file)
@@ -1355,16 +1355,29 @@ static PyObject *SceneObSeq_item( BPy_SceneObSeq * self, int i )
                for (base= scene->base.first; base && i!=index; base= base->next, index++) {}
        /* selected */
        else if (self->mode==EXPP_OBSEQ_SELECTED) {
-               for (base= scene->base.first; base && i!=index; base= base->next)
-                       if (base->flag & SELECT)
-                               index++;
+               for (base= scene->base.first; base; base= base->next) {
+                       if (base->flag & SELECT) {
+                               if (i==index) {
+                                       break;
+                               } else {
+                                       index++;
+                               }
+                       }
+               }
        }
        /* context */
        else if (self->mode==EXPP_OBSEQ_CONTEXT) {
-               if (G.vd)
-                       for (base= scene->base.first; base && i!=index; base= base->next)
-                               if TESTBASE(base)
-                                       index++;
+               if (G.vd) {
+                       for (base= scene->base.first; base; base= base->next) {
+                               if (TESTBASE(base)) {
+                                       if (i==index) {
+                                               break;
+                                       } else {
+                                               index++;
+                                       }
+                               }
+                       }
+               }
        }
        
        if (!(base))
index 521be3b0ceacc6239c59261aa86a117f47b60283..09167c0e117af070188031f5830a30f30434db11 100644 (file)
@@ -651,6 +651,13 @@ class Object:
                Link a new particle system (see Blender.Particle).
                """
                
+       def addVertexGroupsFromArmature(object):
+               """
+               Add vertex groups from armature using the bone heat method
+               This method can be only used with an Object of the type Mesh when NOT in edit mode.
+               @type object: a bpy armature
+               """
+
        def buildParts():
                """
                Recomputes the particle system. This method only applies to an Object of
index f54c2cd4e3bf595f0788340e38b4c904b036d3b6..bfad069f9434ad88ea467e02b8f48875ec510391 100644 (file)
@@ -478,9 +478,11 @@ PyObject *RenderData_Render( BPy_RenderData * self )
        }
 
        else { /* background mode (blender -b file.blend -P script) */
-               Render *re= RE_NewRender("Render");
+               Render *re= RE_NewRender(G.scene->id.name);
 
-               int end_frame = G.scene->r.efra; /* is of type short currently */
+
+
+               int end_frame = G.scene->r.efra;
 
                if (G.scene != self->scene)
                        return EXPP_ReturnPyObjError (PyExc_RuntimeError,
@@ -490,7 +492,7 @@ PyObject *RenderData_Render( BPy_RenderData * self )
 
                RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
 
-               G.scene->r.efra = (short)end_frame;
+               G.scene->r.efra = end_frame;
        }
 
        Py_RETURN_NONE;
@@ -571,7 +573,7 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
                set_scene( oldsce );
        }
        else { /* background mode (blender -b file.blend -P script) */
-               Render *re= RE_NewRender("Render");
+               Render *re= RE_NewRender(G.scene->id.name);
                
                if (G.scene != self->scene)
                        return EXPP_ReturnPyObjError (PyExc_RuntimeError,
index aec1c69b3dca9cfce1689cf3d0f8bbd8f927145e..8f429f7dd906f9a0eae9be6b5dbf74f981e7f83d 100644 (file)
@@ -70,7 +70,7 @@ typedef struct Isect {
        int ob_last;
 
        short isect;                    /* which half of quad */
-       short mode;                             /* RE_RAYSHADOW, RE_RAYMIRROR, RE_RAYSHADOW_TRA */
+       short mode;                             /* RE_RAY_SHADOW, RE_RAY_MIRROR, RE_RAY_SHADOW_TRA */
        int lay;                                /* -1 default, set for layer lamps */
 
        /* only used externally */
index 73db5c4b0be798e09cf7ac940f024075d07c772c..aa4e40739da9f222dca2220b5e10fe4422030274 100644 (file)
@@ -241,7 +241,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
                /* append or set matrix depending on dupli */
                if(obi->flag & R_DUPLI_TRANSFORMED) {
                        Mat4CpyMat4(tmpmat, obi->mat);
-                       Mat4MulMat4(obi->mat, tmat, tmpmat);
+                       Mat4MulMat4(obi->mat, tmpmat, tmat);
                }
                else if(mode==1)
                        Mat4CpyMat4(obi->mat, tmat);
index fb699f5b38273e7f085c3ff1b279604f4106e313..ebb52c491323d2f71141f43dd9781004c3c79b96 100644 (file)
@@ -993,6 +993,7 @@ RenderStats *RE_GetStats(Render *re)
        return &re->i;
 }
 
+/* Note, when rendering from a scene, ALWAYS use G.scene->id.name, else compositing wont work */
 Render *RE_NewRender(const char *name)
 {
        Render *re;
index 8fd07001bd114aca12e2d5787fec357ef4074b66..1155d2ea81770585ae378545482eb3d3e1555740 100644 (file)
@@ -1473,14 +1473,15 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys)
        int tot;
        float *vec;
        
-       if(resol>16) resol= 16;
-       
        tot= 2*resol*resol;
 
        if (type & WO_AORNDSMP) {
-               static float sphere[2*3*256];
+               float *sphere;
                int a;
                
+               // always returns table
+               sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
+
                /* total random sampling. NOT THREADSAFE! (should be removed, is not useful) */
                vec= sphere;
                for (a=0; a<tot; a++, vec+=3) {
@@ -1495,7 +1496,8 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys)
                float ang, *vec1;
                int a;
                
-               sphere= threadsafe_table_sphere(1, thread, xs, ys, tot);        // returns table if xs and ys were equal to last call
+               // returns table if xs and ys were equal to last call
+               sphere= threadsafe_table_sphere(1, thread, xs, ys, tot);
                if(sphere==NULL) {
                        sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
                        
@@ -1663,7 +1665,7 @@ void ray_ao_spheresamp(ShadeInput *shi, float *shadfac)
        float *vec, *nrm, div, bias, sh=0.0f;
        float maxdist = R.wrld.aodist;
        float dxyview[3];
-       int j= -1, tot, actual=0, skyadded=0, aocolor;
+       int j= -1, tot, actual=0, skyadded=0, aocolor, resol= R.wrld.aosamp;
        
        isec.faceorig= (RayFace*)shi->vlr;
        isec.oborig= RAY_OBJECT_SET(&R, shi->obi);
@@ -1690,14 +1692,16 @@ void ray_ao_spheresamp(ShadeInput *shi, float *shadfac)
        if(shi->mat->mode & MA_ONLYSHADOW)
                aocolor= WO_AOPLAIN;
        
-       vec= sphere_sampler(R.wrld.aomode, R.wrld.aosamp, shi->thread, shi->xs, shi->ys);
+       if(resol>32) resol= 32;
+       
+       vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys);
        
        // warning: since we use full sphere now, and dotproduct is below, we do twice as much
-       tot= 2*R.wrld.aosamp*R.wrld.aosamp;
+       tot= 2*resol*resol;
 
        if(aocolor == WO_AOSKYTEX) {
-               dxyview[0]= 1.0f/(float)R.wrld.aosamp;
-               dxyview[1]= 1.0f/(float)R.wrld.aosamp;
+               dxyview[0]= 1.0f/(float)resol;
+               dxyview[1]= 1.0f/(float)resol;
                dxyview[2]= 0.0f;
        }
        
index f3744fec68bf4f44ed84660a55e73950d912c89e..b1d2d26bc4628a78fbdfc77f2521892201e733d2 100644 (file)
@@ -3094,7 +3094,6 @@ static void editing_panel_font_type(Object *ob, Curve *cu)
 
 void do_curvebuts(unsigned short event)
 {
-       extern Nurb *lastnu;
        extern ListBase editNurb;  /* from editcurve */
        Object *ob;
        Curve *cu;
@@ -3128,13 +3127,15 @@ void do_curvebuts(unsigned short event)
                                if(isNurbsel(nu)) {
                                        if((nu->type & 7)==CU_NURBS) {
                                                if(event<B_UNIFV) {
-                                                       nu->flagu &= 1;
-                                                       nu->flagu += ((event-B_UNIFU)<<1);
+                                                       nu->flagu &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */
+                                                       nu->flagu |= ((event-B_UNIFU)<<1);
+                                                       clamp_nurb_order_u(nu);
                                                        makeknots(nu, 1, nu->flagu>>1);
                                                }
                                                else if(nu->pntsv>1) {
-                                                       nu->flagv &= 1;
-                                                       nu->flagv += ((event-B_UNIFV)<<1);
+                                                       nu->flagv &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */
+                                                       nu->flagv |= ((event-B_UNIFV)<<1);
+                                                       clamp_nurb_order_v(nu);
                                                        makeknots(nu, 2, nu->flagv>>1);
                                                }
                                        }
@@ -3170,15 +3171,13 @@ void do_curvebuts(unsigned short event)
                break;
        case B_SETORDER:
                if(G.obedit) {
-                       nu= lastnu;
+                       nu= get_actNurb();
                        if(nu && (nu->type & 7)==CU_NURBS ) {
-                               if(nu->orderu>nu->pntsu) {
-                                       nu->orderu= nu->pntsu;
+                               if(clamp_nurb_order_u(nu)) {
                                        scrarea_queue_winredraw(curarea);
                                }
                                makeknots(nu, 1, nu->flagu>>1);
-                               if(nu->orderv>nu->pntsv) {
-                                       nu->orderv= nu->pntsv;
+                               if(clamp_nurb_order_v(nu)) {
                                        scrarea_queue_winredraw(curarea);
                                }
                                makeknots(nu, 2, nu->flagv>>1);
@@ -3296,7 +3295,6 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
 {
        Nurb *nu;
        extern ListBase editNurb;  /* from editcurve */
-       extern Nurb *lastnu;
        uiBlock *block;
        short *sp;
 
@@ -3332,8 +3330,11 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
        uiBlockEndAlign(block);
 
        if(ob==G.obedit) {
-               nu= lastnu;
-               if(nu==NULL) nu= lastnu= editNurb.first;
+               nu= get_actNurb();
+               if(nu==NULL && editNurb.first) {
+                       nu= editNurb.first;
+                       set_actNurb(nu);
+               }
                if(nu) {
                        if (ob->type==OB_CURVE) {
                                uiDefBut(block, LABEL, 0, "Tilt",
index c68475088060af846162d08be9927503d0d19e2e..04a497ffdea193a8ab9e632673ddcfcec78844db 100644 (file)
@@ -2681,7 +2681,8 @@ static void lamp_panel_spot(Object *ob, Lamp *la)
                        uiDefButF(block, NUM,B_LAMPREDRAW,"Soft Size",  100,80,200,19, &la->area_size, 0.01, 100.0, 10, 0, "Area light size, doesn't affect energy amount");
                        
                        uiDefButS(block, NUM,0,"Samples:",      100,60,200,19,  &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp)");
-                       uiDefButF(block, NUM,0,"Threshold:",    100,40,200,19,  &la->adapt_thresh, 0.0, 1.0, 100, 0, "Threshold for adaptive sampling, to control what level is considered already in shadow");
+                       if (la->ray_samp_method == LA_SAMP_HALTON)
+                               uiDefButF(block, NUM,0,"Threshold:",    100,40,200,19,  &la->adapt_thresh, 0.0, 1.0, 100, 0, "Threshold for adaptive sampling, to control what level is considered already in shadow");
                }
                else if (la->type == LA_AREA) {
                        uiDefButS(block, MENU, B_REDR, "Adaptive QMC %x1|Constant QMC %x2|Constant Jittered %x0",
@@ -2887,8 +2888,8 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
        
        uiBlockBeginAlign(block);
        if (ELEM(la->type, LA_LOCAL, LA_SPOT) && (la->falloff_type == LA_FALLOFF_SLIDERS)) {
-               uiDefButF(block, NUMSLI,B_LAMPPRV,"Linear ",    120,30,180,19,&la->att1, 0.0, 1.0, 0, 0, "Set the linear distance attenuatation for a quad lamp");
-               uiDefButF(block, NUMSLI,B_LAMPPRV,"Quad ",  120,10,180,19,&la->att2, 0.0, 1.0, 0, 0, "Set the quadratic distance attenuatation for a quad lamp");
+               uiDefButF(block, NUMSLI,B_LAMPPRV,"Linear ",    120,30,180,19,&la->att1, 0.0, 1.0, 0, 0, "Set the linear distance attenuation for a Lin/Quad Weighted lamp");
+               uiDefButF(block, NUMSLI,B_LAMPPRV,"Quad ",  120,10,180,19,&la->att2, 0.0, 1.0, 0, 0, "Set the quadratic distance attenuation for a Lin/Quad Weighted lamp");
        }
        else if(la->type==LA_AREA) {
                if(la->k==0.0) la->k= 1.0;
index 045b98bb7844216120ad6bc87f9d5bd54366ff3a..96ba8c717556990ad689259941bbde07108e92f5 100644 (file)
@@ -2885,7 +2885,7 @@ static int drawDispList(Base *base, int dt)
 /* 5. start filling the arrays                         */
 /* 6. draw the arrays                                          */
 /* 7. clean up                                                         */
-static void draw_new_particle_system(Base *base, ParticleSystem *psys)
+static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt)
 {
        View3D *v3d= G.vd;
        Object *ob=base->object;
@@ -2902,7 +2902,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
        float *vdata=0, *vedata=0, *cdata=0, *ndata=0, *vd=0, *ved=0, *cd=0, *nd=0, xvec[3], yvec[3], zvec[3];
        int a, k, k_max=0, totpart, totpoint=0, draw_as, path_nbr=0;
        int path_possible=0, keys_possible=0, draw_keys=0, totchild=0;
-       int select=ob->flag&SELECT;
+       int select=ob->flag&SELECT, create_cdata=0;
        GLint polygonmode[2];
        char val[32];
 
@@ -2956,8 +2956,10 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
 
        if(select)
                cpack(0xFFFFFF);
-       else if((ma) && (part->draw&PART_DRAW_MAT_COL))
+       else if((ma) && (part->draw&PART_DRAW_MAT_COL)) {
                glColor3f(ma->r,ma->g,ma->b);
+               create_cdata = 1;
+       }
        else
                cpack(0);
 
@@ -3065,19 +3067,25 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                if(draw_as!=PART_DRAW_CIRC){
                        switch(draw_as){
                                case PART_DRAW_AXIS:
-                                       cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_cdata");
-                                       /* no break! */
                                case PART_DRAW_CROSS:
+                                       if(draw_as!=PART_DRAW_CROSS || create_cdata)
+                                               cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_cdata");
                                        vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_vdata");
                                        break;
                                case PART_DRAW_LINE:
+                                       if(create_cdata)
+                                               cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*2*3*sizeof(float), "particle_cdata");
                                        vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*2*3*sizeof(float), "particle_vdata");
                                        break;
                                case PART_DRAW_BB:
+                                       if(create_cdata)
+                                               cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_cdata");
                                        vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_vdata");
                                        ndata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_vdata");
                                        break;
                                default:
+                                       if(create_cdata)
+                                               cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*3*sizeof(float), "particle_cdata");
                                        vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*3*sizeof(float), "particle_vdata");
                        }
                }
@@ -3102,9 +3110,17 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
 
                                pa_time=(cfra-pa->time)/pa->lifetime;
 
-                               if((part->flag&PART_ABS_TIME)==0 && part->ipo){
-                                       calc_ipo(part->ipo, 100*pa_time);
-                                       execute_ipo((ID *)part, part->ipo);
+                               if((part->flag&PART_ABS_TIME)==0){                              
+                                       if(ma && ma->ipo){
+                                               /* correction for lifetime */
+                                               calc_ipo(ma->ipo, 100.0f*pa_time);
+                                               execute_ipo((ID *)ma, ma->ipo);
+                                       }
+                                       if(part->ipo) {
+                                               /* correction for lifetime */
+                                               calc_ipo(part->ipo, 100*pa_time);
+                                               execute_ipo((ID *)part, part->ipo);
+                                       }
                                }
 
                                pa_size=pa->size;
@@ -3121,9 +3137,17 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
 
                                pa_time=psys_get_child_time(psys,cpa,cfra);
 
-                               if((part->flag&PART_ABS_TIME)==0 && part->ipo){
-                                       calc_ipo(part->ipo, 100*pa_time);
-                                       execute_ipo((ID *)part, part->ipo);
+                               if((part->flag&PART_ABS_TIME)==0) {
+                                       if(ma && ma->ipo){
+                                               /* correction for lifetime */
+                                               calc_ipo(ma->ipo, 100.0f*pa_time);
+                                               execute_ipo((ID *)ma, ma->ipo);
+                                       }
+                                       if(part->ipo) {
+                                               /* correction for lifetime */
+                                               calc_ipo(part->ipo, 100*pa_time);
+                                               execute_ipo((ID *)part, part->ipo);
+                                       }
                                }
 
                                pa_size=psys_get_child_size(psys,cpa,cfra,0);
@@ -3161,6 +3185,12 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
 
                                        switch(draw_as){
                                                case PART_DRAW_DOT:
+                                                       if(cd) {
+                                                               cd[0]=ma->r;
+                                                               cd[1]=ma->g;
+                                                               cd[2]=ma->b;
+                                                               cd+=3;
+                                                       }
                                                        if(vd){
                                                                VECCOPY(vd,state.co) vd+=3;
                                                        }
@@ -3181,7 +3211,15 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
 
                                                                VECCOPY(vec2,state.co);
                                                        }
-                                                       else VECSUB(vec2,state.co,vec);
+                                                       else {
+                                                               if(cd) {
+                                                                       cd[0]=cd[3]=cd[6]=cd[9]=cd[12]=cd[15]=ma->r;
+                                                                       cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]=ma->g;
+                                                                       cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma->b;
+                                                                       cd+=18;
+                                                               }
+                                                               VECSUB(vec2,state.co,vec);
+                                                       }
 
                                                        VECADD(vec,state.co,vec);
                                                        VECCOPY(vd,vec); vd+=3;
@@ -3219,11 +3257,25 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                                                                VecMulf(vec,VecLength(state.vel));
                                                        VECADDFAC(vd,state.co,vec,-part->draw_line[0]); vd+=3;
                                                        VECADDFAC(vd,state.co,vec,part->draw_line[1]); vd+=3;
+                                                       if(cd) {
+                                                               cd[0]=cd[3]=ma->r;
+                                                               cd[1]=cd[4]=ma->g;
+                                                               cd[2]=cd[5]=ma->b;
+                                                               cd+=3;
+                                                       }
                                                        break;
                                                case PART_DRAW_CIRC:
+                                                       if(create_cdata)
+                                                               glColor3f(ma->r,ma->g,ma->b);
                                                        drawcircball(GL_LINE_LOOP, state.co, pixsize, imat);
                                                        break;
                                                case PART_DRAW_BB:
+                                                       if(cd) {
+                                                               cd[0]=cd[3]=cd[6]=cd[9]=ma->r;
+                                                               cd[1]=cd[4]=cd[7]=cd[10]=ma->g;
+                                                               cd[2]=cd[5]=cd[8]=cd[11]=ma->b;
+                                                               cd+=12;
+                                                       }
                                                        if(part->draw&PART_DRAW_BB_LOCK && part->bb_align==PART_BB_VIEW){
                                                                VECCOPY(xvec,bb_ob->obmat[0]);
                                                                Normalize(xvec);
@@ -3334,14 +3386,24 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                                float *cd2=0,*cdata2=0;
 
                                glEnableClientState(GL_VERTEX_ARRAY);
-                               glEnableClientState(GL_NORMAL_ARRAY);
-                               glEnable(GL_LIGHTING);
 
-                               glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
-                               glEnable(GL_COLOR_MATERIAL);
+                               if(dt > OB_WIRE) {
+                                       glEnableClientState(GL_NORMAL_ARRAY);
 
-                               if(part->draw&PART_DRAW_MAT_COL)
-                                       glEnableClientState(GL_COLOR_ARRAY);
+                                       if(part->draw&PART_DRAW_MAT_COL)
+                                               glEnableClientState(GL_COLOR_ARRAY);
+
+                                       glEnable(GL_LIGHTING);
+                                       glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+                                       glEnable(GL_COLOR_MATERIAL);
+                               }
+                               else {
+                                       glDisableClientState(GL_NORMAL_ARRAY);
+
+                                       glDisable(GL_COLOR_MATERIAL);
+                                       glDisable(GL_LIGHTING);
+                                       BIF_ThemeColor(TH_WIRE);
+                               }
 
                                if(totchild && (part->draw&PART_DRAW_PARENT)==0)
                                        totpart=0;
@@ -3350,9 +3412,13 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                                for(a=0, pa=psys->particles; a<totpart; a++, pa++){
                                        path=cache[a];
                                        glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
-                                       glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
-                                       if(part->draw&PART_DRAW_MAT_COL)
-                                               glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+
+                                       if(dt > OB_WIRE) {
+                                               glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+                                               if(part->draw&PART_DRAW_MAT_COL)
+                                                       glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+                                       }
+
                                        glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
                                }
                                
@@ -3360,15 +3426,21 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                                for(a=0; a<totchild; a++){
                                        path=cache[a];
                                        glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
-                                       glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
-                                       if(part->draw&PART_DRAW_MAT_COL)
-                                               glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+
+                                       if(dt > OB_WIRE) {
+                                               glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+                                               if(part->draw&PART_DRAW_MAT_COL)
+                                                       glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+                                       }
+
                                        glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
                                }
 
-                               if(part->draw&PART_DRAW_MAT_COL)
-                                       glDisable(GL_COLOR_ARRAY);
-                               glDisable(GL_COLOR_MATERIAL);
+                               if(dt > OB_WIRE) {
+                                       if(part->draw&PART_DRAW_MAT_COL)
+                                               glDisable(GL_COLOR_ARRAY);
+                                       glDisable(GL_COLOR_MATERIAL);
+                               }
 
                                if(cdata2)
                                        MEM_freeN(cdata2);
@@ -3389,7 +3461,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                                else
                                        glDisableClientState(GL_VERTEX_ARRAY);
 
-                               if(ndata && MIN2(G.vd->drawtype, ob->dt)>OB_WIRE){
+                               if(ndata && dt>OB_WIRE){
                                        glEnableClientState(GL_NORMAL_ARRAY);
                                        glNormalPointer(GL_FLOAT, 0, ndata);
                                        glEnable(GL_LIGHTING);
@@ -3399,20 +3471,21 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
                                        glDisable(GL_LIGHTING);
                                }
 
+                               if(cdata){
+                                       glEnableClientState(GL_COLOR_ARRAY);
+                                       glColorPointer(3, GL_FLOAT, 0, cdata);
+                               }
+
                                switch(draw_as){
                                        case PART_DRAW_AXIS:
                                        case PART_DRAW_CROSS:
-                                               if(cdata){
-                                                       glEnableClientState(GL_COLOR_ARRAY);
-                                                       glColorPointer(3, GL_FLOAT, 0, cdata);
-                                               }
                                                glDrawArrays(GL_LINES, 0, 6*totpoint);
                                                break;
                                        case PART_DRAW_LINE:
                                                glDrawArrays(GL_LINES, 0, 2*totpoint);
                                                break;
                                        case PART_DRAW_BB:
-                                               if(MIN2(G.vd->drawtype, ob->dt)<=OB_WIRE)
+                                               if(dt<=OB_WIRE)
                                                        glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
 
                                                glDrawArrays(GL_QUADS, 0, 4*totpoint);
@@ -3466,7 +3539,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
        mymultmatrix(ob->obmat);        // bring back local matrix for dtx
 }
 
-static void draw_particle_edit(Object *ob, ParticleSystem *psys)
+static void draw_particle_edit(Object *ob, ParticleSystem *psys, int dt)
 {
        ParticleEdit *edit = psys->edit;
        ParticleData *pa;
@@ -3479,6 +3552,7 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
        float nosel_col[3];
        char val[32];
 
+       /* create path and child path cache if it doesn't exist already */
        if(psys->pathcache==0){
                PE_hide_keys_time(psys,CFRA);
                psys_cache_paths(ob,psys,CFRA,0);
@@ -3493,11 +3567,13 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
        else if(!(pset->flag & PE_SHOW_CHILD) && psys->childcache)
                free_child_path_cache(psys);
 
+       /* opengl setup */
        if((G.vd->flag & V3D_ZBUF_SELECT)==0)
                glDisable(GL_DEPTH_TEST);
 
        myloadmatrix(G.vd->viewmat);
 
+       /* get selection theme colors */
        BIF_GetThemeColor3ubv(TH_VERTEX_SELECT, sel);
        BIF_GetThemeColor3ubv(TH_VERTEX, nosel);
        sel_col[0]=(float)sel[0]/255.0f;
@@ -3511,41 +3587,61 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
                totchild = psys->totchildcache;
 
        /* draw paths */
-       glEnableClientState(GL_VERTEX_ARRAY);
-       glEnableClientState(GL_NORMAL_ARRAY);
-       glEnableClientState(GL_COLOR_ARRAY);
        if(timed)
                glEnable(GL_BLEND);
 
-       if(pset->brushtype == PE_BRUSH_WEIGHT){
-               glLineWidth(2.0f);
+       glEnableClientState(GL_VERTEX_ARRAY);
+
+       if(dt > OB_WIRE) {
+               /* solid shaded with lighting */
+               glEnableClientState(GL_NORMAL_ARRAY);
                glEnableClientState(GL_COLOR_ARRAY);
+
+               glEnable(GL_COLOR_MATERIAL);
+               glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+       }
+       else {
+               /* flat wire color */
+               glDisableClientState(GL_NORMAL_ARRAY);
                glDisable(GL_LIGHTING);
+               BIF_ThemeColor(TH_WIRE);
        }
 
-       glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
-       glEnable(GL_COLOR_MATERIAL);
-
-       for(i=0, pa=psys->particles, path = psys->pathcache; i<totpart; i++, pa++, path++){
-               glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
-               glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
-               glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
-
-               glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
-       }
+       /* only draw child paths with lighting */
+       if(dt > OB_WIRE)
+               glEnable(GL_LIGHTING);
 
-       glEnable(GL_LIGHTING);
        if(psys->part->draw_as == PART_DRAW_PATH) {
                for(i=0, path=psys->childcache; i<totchild; i++,path++){
                        glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
-                       glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
-                       glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
+                       if(dt > OB_WIRE) {
+                               glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
+                               glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
+                       }
 
                        glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
                }
        }
 
-       glDisable(GL_COLOR_MATERIAL);
+       if(dt > OB_WIRE)
+               glDisable(GL_LIGHTING);
+
+       if(pset->brushtype == PE_BRUSH_WEIGHT) {
+               glLineWidth(2.0f);
+               glEnableClientState(GL_COLOR_ARRAY);
+               glDisable(GL_LIGHTING);
+       }
+
+       /* draw parents last without lighting */
+       for(i=0, pa=psys->particles, path = psys->pathcache; i<totpart; i++, pa++, path++){
+               glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
+               if(dt > OB_WIRE)
+                       glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
+               if(dt > OB_WIRE || pset->brushtype == PE_BRUSH_WEIGHT)
+                       glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
+
+               glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
+       }
 
        /* draw edit vertices */
        if(G.scene->selectmode!=SCE_SELECT_PATH){
@@ -3619,6 +3715,7 @@ static void draw_particle_edit(Object *ob, ParticleSystem *psys)
 
        glDisable(GL_BLEND);
        glDisable(GL_LIGHTING);
+       glDisable(GL_COLOR_MATERIAL);
        glDisableClientState(GL_COLOR_ARRAY);
        glEnableClientState(GL_NORMAL_ARRAY);
        glEnable(GL_DEPTH_TEST);
@@ -5011,12 +5108,12 @@ void draw_object(Base *base, int flag)
                glDepthMask(GL_FALSE);
                
                for(psys=ob->particlesystem.first; psys; psys=psys->next)
-                       draw_new_particle_system(base, psys);
+                       draw_new_particle_system(base, psys, dt);
                
                if(G.f & G_PARTICLEEDIT && ob==OBACT) {
                        psys= PE_get_current(ob);
                        if(psys && !G.obedit && psys_in_edit_mode(psys))
-                               draw_particle_edit(ob, psys);
+                               draw_particle_edit(ob, psys, dt);
                }
                glDepthMask(GL_TRUE); 
                if(col) cpack(col);
index 52e0d3d6f05c794e652ed157c301fe29caacd496..e83ecb1396005ab3273e30b244d13ba421bbfa96 100644 (file)
@@ -3732,18 +3732,22 @@ int play_anim(int mode)
                                        else viewmove(0);
                                }
                        } else if (event==WHEELDOWNMOUSE || (val && event==PADMINUS)) { /* copied from persptoetsen */
-                               /* this min and max is also in viewmove() */
-                               if(G.vd->persp==V3D_CAMOB) {
-                                       G.vd->camzoom-= 10;
-                                       if(G.vd->camzoom<-30) G.vd->camzoom= -30;
+                               if (G.vd) { /* when using the sequencer this can be NULL */
+                                       /* this min and max is also in viewmove() */ 
+                                       if(G.vd->persp==V3D_CAMOB) {
+                                               G.vd->camzoom-= 10;
+                                               if(G.vd->camzoom<-30) G.vd->camzoom= -30;
+                                       }
+                                       else if(G.vd->dist<10.0*G.vd->far) G.vd->dist*=1.2f;
                                }
-                               else if(G.vd->dist<10.0*G.vd->far) G.vd->dist*=1.2f;
                        } else if (event==WHEELUPMOUSE || (val && event==PADPLUSKEY)) { /* copied from persptoetsen */
-                               if(G.vd->persp==V3D_CAMOB) {
-                                       G.vd->camzoom+= 10;
-                                       if(G.vd->camzoom>300) G.vd->camzoom= 300;
+                               if (G.vd) {
+                                       if(G.vd->persp==V3D_CAMOB) {
+                                               G.vd->camzoom+= 10;
+                                               if(G.vd->camzoom>300) G.vd->camzoom= 300;
+                                       }
+                                       else if(G.vd->dist> 0.001*G.vd->grid) G.vd->dist*=.83333f;
                                }
-                               else if(G.vd->dist> 0.001*G.vd->grid) G.vd->dist*=.83333f;
                        } else if(event==MKEY) {
                                if(val) add_marker(CFRA-1);
                        }
index 172e06f5add32a26640e1f4c66a918940cff81a3..39f93510358318ff5565e9357e6b06e197453ace 100644 (file)
@@ -2396,6 +2396,7 @@ void fill_bones_armature(void)
        else if (count == 2) {
                EditBonePoint *ebp, *ebp2;
                float head[3], tail[3];
+               short headtail = 0;
                
                /* check that the points don't belong to the same bone */
                ebp= (EditBonePoint *)points.first;
@@ -2420,7 +2421,7 @@ void fill_bones_armature(void)
                        float distA, distB;
                        
                        /* get cursor location */
-                       VECCOPY (curs, give_cursor());  
+                       VECCOPY(curs, give_cursor());   
                        
                        Mat4Invert(G.obedit->imat, G.obedit->obmat);
                        Mat4MulVecfl(G.obedit->imat, curs);
@@ -2432,26 +2433,47 @@ void fill_bones_armature(void)
                        distB= VecLength(vecB);
                        
                        /* compare distances - closer one therefore acts as direction for bone to go */
-                       if (distA < distB) {
-                               VECCOPY(head, ebp2->vec);
-                               VECCOPY(tail, ebp->vec);
-                       }
-                       else {
-                               VECCOPY(head, ebp->vec);
-                               VECCOPY(tail, ebp2->vec);
-                       }
+                       headtail= (distA < distB) ? 2 : 1;
                }
                else if (ebp->head_owner) {
+                       headtail = 1;
+               }
+               else if (ebp2->head_owner) {
+                       headtail = 2;
+               }
+               
+               /* assign head/tail combinations */
+               if (headtail == 2) {
                        VECCOPY(head, ebp->vec);
                        VECCOPY(tail, ebp2->vec);
                }
-               else if (ebp2->head_owner) {
+               else if (headtail == 1) {
                        VECCOPY(head, ebp2->vec);
                        VECCOPY(tail, ebp->vec);
                }
                
-               /* add new bone */
-               newbone= add_points_bone(head, tail);
+               /* add new bone and parent it to the appropriate end */
+               if (headtail) {
+                       newbone= add_points_bone(head, tail);
+                       
+                       /* do parenting (will need to set connected flag too) */
+                       if (headtail == 2) {
+                               /* ebp tail or head - tail gets priority */
+                               if (ebp->tail_owner)
+                                       newbone->parent= ebp->tail_owner;
+                               else
+                                       newbone->parent= ebp->head_owner;
+                       }
+                       else {
+                               /* ebp2 tail or head - tail gets priority */
+                               if (ebp2->tail_owner)
+                                       newbone->parent= ebp2->tail_owner;
+                               else
+                                       newbone->parent= ebp2->head_owner;
+                       }
+                       
+                       newbone->flag |= BONE_CONNECTED;
+               }
        }
        else {
                // FIXME.. figure out a method for multiple bones
@@ -4097,16 +4119,34 @@ void transform_armature_mirror_update(void)
                        if (eboflip) {
                                /* we assume X-axis flipping for now */
                                if (ebo->flag & BONE_TIPSEL) {
+                                       EditBone *children;
+                                       
                                        eboflip->tail[0]= -ebo->tail[0];
                                        eboflip->tail[1]= ebo->tail[1];
                                        eboflip->tail[2]= ebo->tail[2];
                                        eboflip->rad_tail= ebo->rad_tail;
+
+                                       /* Also move connected children, in case children's name aren't mirrored properly */
+                                       for (children=G.edbo.first; children; children=children->next) {
+                                               if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
+                                                       VECCOPY(children->head, eboflip->tail);
+                                                       children->rad_head = ebo->rad_tail;
+                                               }
+                                       }
                                }
                                if (ebo->flag & BONE_ROOTSEL) {
                                        eboflip->head[0]= -ebo->head[0];
                                        eboflip->head[1]= ebo->head[1];
                                        eboflip->head[2]= ebo->head[2];
                                        eboflip->rad_head= ebo->rad_head;
+                                       
+                                       /* Also move connected parent, in case parent's name isn't mirrored properly */
+                                       if (eboflip->parent && eboflip->flag & BONE_CONNECTED)
+                                       {
+                                               EditBone *parent = eboflip->parent;
+                                               VECCOPY(parent->tail, eboflip->head);
+                                               parent->rad_tail = ebo->rad_head;
+                                       }
                                }
                                if (ebo->flag & BONE_SELECTED) {
                                        eboflip->dist= ebo->dist;
index 7572391b3838010c54b38753cddd38538eea2616..bd0abe83ee4b0fa4669de2ba725898b694369de4 100644 (file)
@@ -99,7 +99,7 @@
 
 ListBase editNurb;
 BPoint *lastselbp;
-Nurb *lastnu;          /* for selected */
+int actnu;             /* for selected */
 
 
 /*  void freeNurblist(ListBase *lb); already declared in the kernel */
@@ -109,6 +109,23 @@ float nurbcircle[8][2]= {
        {0.0,  1.0}, { 1.0,  1.0}, { 1.0, 0.0}, { 1.0, -1.0}
 };
 
+
+/* this replaces the active flag used in uv/face mode */
+void set_actNurb(Nurb *nu)
+{
+       if (nu==NULL) {
+               actnu = -1;
+       } else {
+               actnu = BLI_findindex(&editNurb, nu);
+       }
+}
+
+Nurb * get_actNurb( void )
+{
+       return BLI_findlink(&editNurb, actnu);
+}
+
+
 /* ******************* SELECTION FUNCTIONS ********************* */
 
 /* returns 1 in case (de)selection was successful */
@@ -318,14 +335,14 @@ void load_editNurb()
                                BLI_addtail(&(cu->nurb), newnu);
                                
                                if((nu->type & 7)==CU_NURBS) {
-                                       if(nu->pntsu < nu->orderu) nu->orderu= nu->pntsu;
+                                       clamp_nurb_order_u(nu);
                                }
                        }
                }
                
        }
        
-       lastnu= NULL;   /* for selected */
+       set_actNurb(NULL);
 }
 
 void make_editNurb()
@@ -361,8 +378,7 @@ void make_editNurb()
        else G.obedit= NULL;
        
        countall();
-       
-       lastnu= NULL;   /* for selected */
+       set_actNurb(NULL);
 }
 
 void remake_editNurb()
@@ -457,8 +473,7 @@ void separate_nurb()
        countall();
        allqueue(REDRAWVIEW3D, 0);
        allqueue(REDRAWBUTSEDIT, 0);
-
-       lastnu= NULL;   /* for selected */
+       set_actNurb(NULL);
 }
 
 /* ******************* FLAGS ********************* */
@@ -640,7 +655,7 @@ void deleteflagNurb(short flag)
                }
                if(a==0) {
                        BLI_remlink(&editNurb, nu);
-                       freeNurb(nu);
+                       freeNurb(nu); nu=NULL;
                }
                else {
                        /* is nurb in U direction selected */
@@ -674,7 +689,7 @@ void deleteflagNurb(short flag)
                                nu->pntsv= newv;
                                MEM_freeN(nu->bp);
                                nu->bp= newbp;
-                               if(nu->orderv>nu->pntsv) nu->orderv= nu->pntsv;
+                               clamp_nurb_order_v(nu);
 
                                makeknots(nu, 2, nu->flagv>>1);
                        }
@@ -714,13 +729,13 @@ void deleteflagNurb(short flag)
                                                nu->pntsu= nu->pntsv;
                                                nu->pntsv= 1;
                                                SWAP(short, nu->orderu, nu->orderv);
-                                               if(nu->orderu>nu->pntsu) nu->orderu= nu->pntsu;
+                                               clamp_nurb_order_u(nu);
                                                if(nu->knotsv) MEM_freeN(nu->knotsv);
-                                               nu->knotsv= 0;
+                                               nu->knotsv= NULL;
                                        }
                                        else {
                                                nu->pntsu= newu;
-                                               if(nu->orderu>nu->pntsu) nu->orderu= nu->pntsu;
+                                               clamp_nurb_order_u(nu);
                                        }
                                        makeknots(nu, 1, nu->flagu>>1);
                                }
@@ -878,7 +893,7 @@ void adduplicateflagNurb(short flag)
                                        newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN");  
                                        memcpy(newnu, nu, sizeof(Nurb));
                                        BLI_addtail(&editNurb, newnu);
-                                       lastnu= newnu;
+                                       set_actNurb(newnu);
                                        newnu->pntsu= enda-starta+1;
                                        newnu->bezt=
                                                (BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN");  
@@ -891,8 +906,10 @@ void adduplicateflagNurb(short flag)
                                                bezt1++;
                                        }
 
-                                       if(nu->flagu & 1) {
-                                               if(starta!=0 || enda!=nu->pntsu-1) newnu->flagu--;
+                                       if(nu->flagu & CU_CYCLIC) {
+                                               if(starta!=0 || enda!=nu->pntsu-1) {
+                                                       newnu->flagu &= ~CU_CYCLIC;
+                                               }
                                        }
                                }
                                bezt++;
@@ -913,7 +930,7 @@ void adduplicateflagNurb(short flag)
                                if(enda>=starta) {
                                        newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3");  
                                        memcpy(newnu, nu, sizeof(Nurb));
-                                       lastnu= newnu;
+                                       set_actNurb(newnu);
                                        BLI_addtail(&editNurb, newnu);
                                        newnu->pntsu= enda-starta+1;
                                        newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4");
@@ -926,12 +943,14 @@ void adduplicateflagNurb(short flag)
                                                bp1++;
                                        }
 
-                                       if(nu->flagu & 1) {
-                                               if(starta!=0 || enda!=nu->pntsu-1) newnu->flagu--;
+                                       if(nu->flagu & CU_CYCLIC) {
+                                               if(starta!=0 || enda!=nu->pntsu-1) {
+                                                       newnu->flagu &= ~CU_CYCLIC;
+                                               }
                                        }
 
                                        /* knots */
-                                       newnu->knotsu= 0;
+                                       newnu->knotsu= NULL;
                                        makeknots(newnu, 1, newnu->flagu>>1);
                                }
                                bp++;
@@ -971,14 +990,16 @@ void adduplicateflagNurb(short flag)
                                        newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
                                        memcpy(newnu, nu, sizeof(Nurb));
                                        BLI_addtail(&editNurb, newnu);
-                                       lastnu= newnu;
+                                       set_actNurb(newnu);
                                        newnu->pntsu= newu;
                                        newnu->pntsv= newv;
                                        newnu->bp =
                                                (BPoint*)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6");
-                                       newnu->orderu= MIN2(nu->orderu, newu);
-                                       newnu->orderv= MIN2(nu->orderv, newv);
-
+                                       clamp_nurb_order_u(newnu);
+                                       clamp_nurb_order_v(newnu);
+                                       
+                                       newnu->knotsu= newnu->knotsv= NULL;
+                                       
                                        bp= newnu->bp;
                                        bp1= nu->bp;
                                        for(a=0; a<nu->pntsv; a++) {
@@ -990,23 +1011,20 @@ void adduplicateflagNurb(short flag)
                                                        }
                                                }
                                        }
-                                       if(nu->pntsu==newnu->pntsu) {
-                                               newnu->knotsu= MEM_mallocN(sizeof(float)*KNOTSU(nu), "adduplicateN6");
-                                               memcpy(newnu->knotsu, nu->knotsu, sizeof(float)*KNOTSU(nu));
-                                       }
-                                       else {
-                                               newnu->knotsu= 0;
-                                               makeknots(newnu, 1, newnu->flagu>>1);
-                                       }
-                                       if(nu->pntsv==newnu->pntsv) {
-                                               newnu->knotsv= MEM_mallocN(sizeof(float)*KNOTSV(nu), "adduplicateN7");
-                                               memcpy(newnu->knotsv, nu->knotsv, sizeof(float)*KNOTSV(nu));
+                                       if (check_valid_nurb_u(newnu)) {
+                                               if(nu->pntsu==newnu->pntsu && nu->knotsu) {
+                                                       newnu->knotsu= MEM_dupallocN( nu->knotsu );
+                                               } else {
+                                                       makeknots(newnu, 1, newnu->flagu>>1);
+                                               }
                                        }
-                                       else {
-                                               newnu->knotsv= 0;
-                                               makeknots(newnu, 2, newnu->flagv>>1);
+                                       if (check_valid_nurb_v(newnu)) {
+                                               if(nu->pntsv==newnu->pntsv && nu->knotsv) {
+                                                       newnu->knotsv= MEM_dupallocN( nu->knotsv );
+                                               } else {
+                                                       makeknots(newnu, 2, newnu->flagv>>1);
+                                               }
                                        }
-
                                }
                                MEM_freeN(usel);
                        }
@@ -1015,7 +1033,7 @@ void adduplicateflagNurb(short flag)
                nu= nu->prev;
        }
        
-       /* lastnu changed */
+       /* actnu changed */
        allqueue(REDRAWBUTSEDIT, 0);
 }
 
@@ -1569,7 +1587,7 @@ void subdivideNurb()
            newly created. Old points are discarded.
         */
                        /* count */
-                       if(nu->flagu & 1) {
+                       if(nu->flagu & CU_CYCLIC) {
                                a= nu->pntsu;
                                bezt= nu->bezt;
                                prevbezt= bezt+(a-1);
@@ -1590,7 +1608,7 @@ void subdivideNurb()
                                beztnew =
                                        (BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb");
                                beztn= beztnew;
-                               if(nu->flagu & 1) {
+                               if(nu->flagu & CU_CYCLIC) {
                                        a= nu->pntsu;
                                        bezt= nu->bezt;
                                        prevbezt= bezt+(a-1);
@@ -1622,7 +1640,7 @@ void subdivideNurb()
                                                VecMidf(beztn->vec[1], vec+9, vec+12);
                                                VECCOPY(beztn->vec[2], vec+12);
                                                /* handle of next bezt */
-                                               if(a==0 && (nu->flagu & 1)) {VECCOPY(beztnew->vec[0], vec+6);}
+                                               if(a==0 && (nu->flagu & CU_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);}
                                                else {VECCOPY(bezt->vec[0], vec+6);}
                                                
                                                beztn->radius = (prevbezt->radius + bezt->radius)/2.0f;
@@ -1635,7 +1653,7 @@ void subdivideNurb()
                                        bezt++;
                                }
                                /* last point */
-                               if((nu->flagu & 1)==0) memcpy(beztn, prevbezt, sizeof(BezTriple));
+                               if((nu->flagu & CU_CYCLIC)==0) memcpy(beztn, prevbezt, sizeof(BezTriple));
 
                                MEM_freeN(nu->bezt);
                                nu->bezt= beztnew;
@@ -1652,7 +1670,7 @@ void subdivideNurb()
            stable... nzc 30-5-'00
          */
                        /* count */
-                       if(nu->flagu & 1) {
+                       if(nu->flagu & CU_CYCLIC) {
                                a= nu->pntsu*nu->pntsv;
                                bp= nu->bp;
                                prevbp= bp+(a-1);
@@ -1674,7 +1692,7 @@ void subdivideNurb()
                                        (BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2");
                                bpn= bpnew;
 
-                               if(nu->flagu & 1) {
+                               if(nu->flagu & CU_CYCLIC) {
                                        a= nu->pntsu;
                                        bp= nu->bp;
                                        prevbp= bp+(a-1);
@@ -1701,7 +1719,7 @@ void subdivideNurb()
                                        prevbp= bp;
                                        bp++;
                                }
-                               if((nu->flagu & 1)==0) memcpy(bpn, prevbp, sizeof(BPoint));     /* last point */
+                               if((nu->flagu & CU_CYCLIC)==0) memcpy(bpn, prevbp, sizeof(BPoint));     /* last point */
 
                                MEM_freeN(nu->bp);
                                nu->bp= bpnew;
@@ -2075,7 +2093,7 @@ int convertspline(short type, Nurb *nu)
                        nu->type &= ~7;
                        nu->type+= 4;
                        nu->orderu= 4;
-                       nu->flagu &= 1;
+                       nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
                        nu->flagu += 4;
                        makeknots(nu, 1, nu->flagu>>1);
                        a= nu->pntsu*nu->pntsv;
@@ -2126,10 +2144,10 @@ int convertspline(short type, Nurb *nu)
                        nu->orderv= 1;
                        nu->type &= ~7;
                        nu->type+= type;
-                       if(nu->flagu & 1) c= nu->orderu-1; 
+                       if(nu->flagu & CU_CYCLIC) c= nu->orderu-1; 
                        else c= 0;
                        if(type== 4) {
-                               nu->flagu &= 1;
+                               nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
                                nu->flagu += 4;
                                makeknots(nu, 1, nu->flagu>>1);
                        }
@@ -2139,9 +2157,9 @@ int convertspline(short type, Nurb *nu)
                if(type==0) {                   /* to Poly */
                        nu->type &= ~7;
                        if(nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */
-                       nu->knotsu= 0;
+                       nu->knotsu= NULL;
                        if(nu->knotsv) MEM_freeN(nu->knotsv);
-                       nu->knotsv= 0;
+                       nu->knotsv= NULL;
                }
                else if(type==CU_BEZIER) {              /* to Bezier */
                        nr= nu->pntsu/3;
@@ -2170,7 +2188,7 @@ int convertspline(short type, Nurb *nu)
                                MEM_freeN(nu->bp);
                                nu->bp= 0;
                                MEM_freeN(nu->knotsu);
-                               nu->knotsu= 0;
+                               nu->knotsu= NULL;
                                nu->pntsu= nr;
                                nu->type &= ~7;
                                nu->type+= 1;
@@ -2481,7 +2499,7 @@ void merge_nurb()
        BLI_freelistN(&nsortbase);
        
        countall();
-       lastnu= NULL;
+       set_actNurb(NULL);
 
        DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
 
@@ -2527,7 +2545,7 @@ void addsegment_nurb()
        
        /* find both nurbs and points, nu1 will be put behind nu2 */
        for(nu= editNurb.first; nu; nu= nu->next) {
-               if((nu->flagu & 1)==0) {    /* not cyclic */
+               if((nu->flagu & CU_CYCLIC)==0) {    /* not cyclic */
                        if( (nu->type & 7)==CU_BEZIER ) {
                                bezt= nu->bezt;
                                if(nu1==0) {
@@ -2594,7 +2612,7 @@ void addsegment_nurb()
                                nu1->bezt= bezt;
                                nu1->pntsu+= nu2->pntsu;
                                BLI_remlink(&editNurb, nu2);
-                               freeNurb(nu2);
+                               freeNurb(nu2); nu2= NULL;
                                calchandlesNurb(nu1);
                        }
                        else {
@@ -2632,11 +2650,11 @@ void addsegment_nurb()
                                                }
                                        }
                                }
-                               freeNurb(nu2);
+                               freeNurb(nu2); nu2= NULL;
                        }
                }
                
-               lastnu= NULL;   /* for selected */
+               set_actNurb(NULL);      /* for selected */
 
                DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
 
@@ -2704,8 +2722,8 @@ void mouse_nurb()
 
        rightmouse_transform();
        
-       if(nu!=lastnu) {
-               lastnu= nu;
+       if(nu!=get_actNurb()) {
+               set_actNurb(nu);
                allqueue(REDRAWBUTSEDIT, 0);
        }
        
@@ -2808,7 +2826,7 @@ static void spin_nurb(float *dvec, short mode)
                for(nu= editNurb.first; nu; nu= nu->next) {
                        if(isNurbsel(nu)) {
                                nu->orderv= 4;
-                               nu->flagv |= 1;
+                               nu->flagv |= CU_CYCLIC;
                                makeknots(nu, 2, nu->flagv>>1);
                        }
                }
@@ -3006,8 +3024,8 @@ void makecyclicNurb()
                                bp= nu->bp;
                                while(a--) {
                                        if( bp->f1 & SELECT ) {
-                                               if(nu->flagu & CU_CYCLIC) nu->flagu--;
-                                               else nu->flagu++;
+                                               if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
+                                               else nu->flagu |= CU_CYCLIC;
                                                break;
                                        }
                                        bp++;
@@ -3018,8 +3036,8 @@ void makecyclicNurb()
                                bezt= nu->bezt;
                                while(a--) {
                                        if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
-                                               if(nu->flagu & CU_CYCLIC) nu->flagu--;
-                                               else nu->flagu++;
+                                               if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
+                                               else nu->flagu |= CU_CYCLIC;
                                                break;
                                        }
                                        bezt++;
@@ -3027,26 +3045,28 @@ void makecyclicNurb()
                                calchandlesNurb(nu);
                        }
                        else if(nu->pntsv==1 && (nu->type & 7)==CU_NURBS) {
-                               a= nu->pntsu;
-                               bp= nu->bp;
-                               while(a--) {
-                                       if( bp->f1 & SELECT ) {
-                                               if(nu->flagu & CU_CYCLIC) nu->flagu--;
-                                               else {
-                                                       nu->flagu++;
-                                                       nu->flagu &= ~2;        /* endpoint flag, fixme */
-                                                       fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
-                                                       b= (nu->orderu+nu->pntsu);
-                                                       memcpy(fp, nu->knotsu, sizeof(float)*b);
-                                                       MEM_freeN(nu->knotsu);
-                                                       nu->knotsu= fp;
+                               if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */
+                                       a= nu->pntsu;
+                                       bp= nu->bp;
+                                       while(a--) {
+                                               if( bp->f1 & SELECT ) {
+                                                       if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
+                                                       else {
+                                                               nu->flagu |= CU_CYCLIC;
+                                                               nu->flagu &= ~2;        /* endpoint flag, fixme */
+                                                               fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
+                                                               b= (nu->orderu+nu->pntsu);
+                                                               memcpy(fp, nu->knotsu, sizeof(float)*b);
+                                                               MEM_freeN(nu->knotsu);
+                                                               nu->knotsu= fp;
                                                        
-                                                       makeknots(nu, 1, 0);    /* 1==u  0==uniform */
+                                                               makeknots(nu, 1, 0);    /* 1==u  0==uniform */
                                                        
+                                                       }
+                                                       break;
                                                }
-                                               break;
+                                               bp++;
                                        }
-                                       bp++;
                                }
                        }
                        else if(nu->type==CU_NURBS) {
@@ -3060,29 +3080,37 @@ void makecyclicNurb()
        
                                        if( bp->f1 & SELECT) {
                                                if(cyclmode==1 && nu->pntsu>1) {
-                                                       if(nu->flagu & CU_CYCLIC) nu->flagu--;
+                                                       if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
                                                        else {
-                                                               nu->flagu++;
-                                                               fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
-                                                               b= (nu->orderu+nu->pntsu);
-                                                               memcpy(fp, nu->knotsu, sizeof(float)*b);
-                                                               MEM_freeN(nu->knotsu);
-                                                               nu->knotsu= fp;
+                                                               nu->flagu |= CU_CYCLIC;
+                                                               if (check_valid_nurb_u(nu)) {
+                                                                       fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
+                                                                       b= (nu->orderu+nu->pntsu);
+                                                                       if (nu->knotsu) { /* null if check_valid_nurb_u failed before but is valid now */
+                                                                               memcpy(fp, nu->knotsu, sizeof(float)*b);
+                                                                               MEM_freeN(nu->knotsu);
+                                                                       }
+                                                                       nu->knotsu= fp;
                                                                
-                                                               makeknots(nu, 1, 0);    /* 1==u  0==uniform */
+                                                                       makeknots(nu, 1, 0);    /* 1==u  0==uniform */
+                                                               }
                                                        }
                                                }
                                                if(cyclmode==2 && nu->pntsv>1) {
                                                        if(nu->flagv & 1) nu->flagv--;
                                                        else {
                                                                nu->flagv++;
-                                                               fp= MEM_mallocN(sizeof(float)*KNOTSV(nu), "makecyclicN");
-                                                               b= (nu->orderv+nu->pntsv);
-                                                               memcpy(fp, nu->knotsv, sizeof(float)*b);
-                                                               MEM_freeN(nu->knotsv);
-                                                               nu->knotsv= fp;
+                                                               if (check_valid_nurb_v(nu)) {
+                                                                       fp= MEM_mallocN(sizeof(float)*KNOTSV(nu), "makecyclicN");
+                                                                       b= (nu->orderv+nu->pntsv);
+                                                                       if (nu->knotsv) { /* null if check_valid_nurb_v failed before but is valid now */
+                                                                               memcpy(fp, nu->knotsv, sizeof(float)*b);
+                                                                               MEM_freeN(nu->knotsv);
+                                                                       }
+                                                                       nu->knotsv= fp;
                                                                
-                                                               makeknots(nu, 2, 0);    /* 2==v  0==uniform */
+                                                                       makeknots(nu, 2, 0);    /* 2==v  0==uniform */
+                                                               }
                                                        }
                                                }
                                                break;
@@ -3638,7 +3666,7 @@ void delNurb()
                                        }
                                        if(a==0) {
                                                BLI_remlink(&editNurb, nu);
-                                               freeNurb(nu);
+                                               freeNurb(nu); nu= NULL;
                                        }
                                }
                        }
@@ -3654,15 +3682,18 @@ void delNurb()
                                        }
                                        if(a==0) {
                                                BLI_remlink(&editNurb, nu);
-                                               freeNurb(nu);
+                                               freeNurb(nu); nu= NULL;
                                        }
                                }
                        }
                        
-                       /* Never allow the order to exceed the number of points */
-                       if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
-                               nu->orderu = nu->pntsu;
+                       /* Never allow the order to exceed the number of points
+                       - note, this is ok but changes unselected nurbs, disable for now */
+                       /*
+                       if ((nu!= NULL) && ((nu->type & 7)==CU_NURBS)) {
+                               clamp_nurb_order_u(nu);
                        }
+                       */
                        nu= next;
                }
                /* 2nd loop, delete small pieces: just for curves */
@@ -3710,10 +3741,12 @@ void delNurb()
                                        MEM_freeN(nu->bp);
                                        nu->bp= bp1;
                                        
-                                       /* Never allow the order to exceed the number of points */
-                                       if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
-                                               nu->orderu = nu->pntsu;
-                                       }
+                                       /* Never allow the order to exceed the number of points\
+                                       - note, this is ok but changes unselected nurbs, disable for now */
+                                       /*
+                                       if ((nu->type & 7)==CU_NURBS) {
+                                               clamp_nurb_order_u(nu);
+                                       }*/
                                }
                                makeknots(nu, 1, nu->flagu>>1);
                        }
@@ -3736,10 +3769,10 @@ void delNurb()
                                                bezt2= bezt+1;
                                                if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) ;
                                                else {  /* maybe do not make cyclic */
-                                                       if(a==0 && (nu->flagu & 1) ) {
+                                                       if(a==0 && (nu->flagu & CU_CYCLIC) ) {
                                                                bezt2= bezt+(nu->pntsu-1);
                                                                if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) {
-                                                                       nu->flagu--;
+                                                                       nu->flagu &= ~CU_CYCLIC;
                                                                        DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
                                                                        allqueue(REDRAWVIEW3D, 0);
                                                                        allqueue(REDRAWBUTSEDIT, 0);
@@ -3763,10 +3796,10 @@ void delNurb()
                                                bp2= bp+1;
                                                if( bp2->f1 & 1 ) ;
                                                else {  /* maybe do not make cyclic */
-                                                       if(a==0 && (nu->flagu & 1) ) {
+                                                       if(a==0 && (nu->flagu & CU_CYCLIC) ) {
                                                                bp2= bp+(nu->pntsu-1);
-                                                               if( bp2->f1 & 1 ) {
-                                                                       nu->flagu--;
+                                                               if( bp2->f1 & SELECT ) {
+                                                                       nu->flagu &= ~CU_CYCLIC;
                                                                        DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
                                                                        allqueue(REDRAWVIEW3D, 0);
                                                                        allqueue(REDRAWBUTSEDIT, 0);
@@ -3790,16 +3823,16 @@ void delNurb()
                        if(bezt1) {
                                if(nu1->pntsu==2) {     /* remove completely */
                                        BLI_remlink(&editNurb, nu);
-                                       freeNurb(nu);
+                                       freeNurb(nu); nu = NULL;
                                }
-                               else if(nu1->flagu & 1) {       /* cyclic */
+                               else if(nu1->flagu & CU_CYCLIC) {       /* cyclic */
                                        bezt =
                                                (BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1");
                                        memcpy(bezt, nu1->bezt,(cut+1)*sizeof(BezTriple));
                                        a= nu1->pntsu-cut-1;
                                        memcpy(nu1->bezt, bezt2, a*sizeof(BezTriple));
                                        memcpy(nu1->bezt+a, bezt, (cut+1)*sizeof(BezTriple));
-                                       nu1->flagu--;
+                                       nu1->flagu &= ~CU_CYCLIC;
                                        MEM_freeN(bezt);
                                        calchandlesNurb(nu);
                                }
@@ -3832,16 +3865,16 @@ void delNurb()
                        else if(bp1) {
                                if(nu1->pntsu==2) {     /* remove completely */
                                        BLI_remlink(&editNurb, nu);
-                                       freeNurb(nu);
+                                       freeNurb(nu); nu= NULL;
                                }
-                               else if(nu1->flagu & 1) {       /* cyclic */
+                               else if(nu1->flagu & CU_CYCLIC) {       /* cyclic */
                                        bp =
                                                (BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5");
                                        memcpy(bp, nu1->bp,(cut+1)*sizeof(BPoint));
                                        a= nu1->pntsu-cut-1;
                                        memcpy(nu1->bp, bp2, a*sizeof(BPoint));
                                        memcpy(nu1->bp+a, bp, (cut+1)*sizeof(BPoint));
-                                       nu1->flagu--;
+                                       nu1->flagu &= ~CU_CYCLIC;
                                        MEM_freeN(bp);
                                }
                                else {                  /* add new curve */
@@ -4151,7 +4184,7 @@ Nurb *addNurbprim(int type, int stype, int newname)
                if((type & 7)==CU_BEZIER) {
                        nu->pntsu= 4;
                        nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
-                       nu->flagu= 1;
+                       nu->flagu= CU_CYCLIC;
                        bezt= nu->bezt;
 
                        for(a=0;a<3;a++) {
@@ -4200,7 +4233,7 @@ Nurb *addNurbprim(int type, int stype, int newname)
                        nu->pntsv= 1;
                        nu->orderu= 4;
                        nu->bp= callocstructN(BPoint, 8, "addNurbprim6");
-                       nu->flagu= 1;
+                       nu->flagu= CU_CYCLIC;
                        bp= nu->bp;
 
                        for(a=0; a<8; a++) {
@@ -4592,10 +4625,6 @@ static void undoCurve_to_editCurve(void *lbv)
 {
        ListBase *lb= lbv;
        Nurb *nu, *newnu;
-       int nr, lastnunr= 0;
-
-       /* we try to restore lastnu too, for buttons */
-       for(nu= editNurb.first; nu; nu = nu->next, lastnunr++) if(nu==lastnu) break;
        
        freeNurblist(&editNurb);
 
@@ -4604,9 +4633,6 @@ static void undoCurve_to_editCurve(void *lbv)
                newnu= duplicateNurb(nu);
                BLI_addtail(&editNurb, newnu);
        }
-       /* restore */
-       for(nr=0, lastnu= editNurb.first; lastnu; lastnu = lastnu->next, nr++) if(nr==lastnunr) break;
-       
 }
 
 static void *editCurve_to_undoCurve(void)
index afafc4f2590d409b23aa4bf601387c54fc75db71..9057556b7969456f417ecfa402cad234aab0f322 100644 (file)
@@ -166,13 +166,14 @@ static void snode_handle_recalc(SpaceNode *snode)
                        snode->nodetree->test_break= NULL;
                        waitcursor(0);
                        
-                       allqueue(REDRAWNODE, 1);
                        allqueue(REDRAWIMAGE, 1);
                        if(G.scene->r.scemode & R_DOCOMP) {
                                BIF_redraw_render_rect();       /* seems to screwup display? */
                                mywinset(curarea->win);
                        }
                }
+
+               allqueue(REDRAWNODE, 1);
        }
 }
 
index ab8e53c3cb3052238e3f4bb94ac3e744935d1111..6582866d9a167b330b158e5ff19c2c040b594884 100644 (file)
@@ -3394,6 +3394,7 @@ static int ui_do_but_HSVCUBE(uiBut *but)
                        /* we redraw the entire block */
                        for (bt= but->block->buttons.first; bt; bt= bt->next) {
                                if(but->poin == bt->poin) VECCOPY(bt->hsv, but->hsv);
+                               ui_check_but(bt);
                                ui_draw_but(bt);
                        }
                        ui_block_flush_back(but->block);
index e27e772edeed83934ecf5a87618c7fab69b3fe95..ac165d6aeb2fea6168c17921af14b069ff11c1cd 100644 (file)
@@ -957,6 +957,12 @@ int *mesh_get_x_mirror_faces(Object *ob)
                mirrormf.v3= mirrorverts[mf->v1];
                mirrormf.v4= (mf->v4)? mirrorverts[mf->v4]: 0;
 
+               /* make sure v4 is not 0 if a quad */
+               if(mf->v4 && mirrormf.v4==0) {
+                       SWAP(int, mirrormf.v1, mirrormf.v3);
+                       SWAP(int, mirrormf.v2, mirrormf.v4);
+               }
+
                hashmf= BLI_ghash_lookup(fhash, &mirrormf);
                if(hashmf) {
                        mirrorfaces[a*2]= hashmf - mface;
index 4c97a8fdbdf20ce7078a04805ca10810ef8abce6..dcceea971f7f30e3299f6ba6cca02fb8bc6384ac 100644 (file)
@@ -659,6 +659,10 @@ void pose_copy_menu(void)
                                                free_constraints(&pchan->constraints);
                                                copy_constraints(&pchan->constraints, &pchanact->constraints);
                                                pchan->constflag = pchanact->constflag;
+                                               
+                                               if (ob->pose) {
+                                                       ob->pose->flag |= POSE_RECALC;
+                                               }
                                        }
                                                break;
                                        case 6: /* Transform Locks */
@@ -741,6 +745,10 @@ void pose_copy_menu(void)
                }
                BLI_freelistN(&const_copy);
                update_pose_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
+               
+               if (ob->pose) {
+                       ob->pose->flag |= POSE_RECALC;
+               }
        }
        
        DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);   // and all its relations
index 1aca097e3731684c1ccdabc54aa5b6e632b6094a..bf519dd6e9cceb6824db6eacfe49897e76c5c358 100644 (file)
@@ -1632,6 +1632,36 @@ static void copy_to_ibuf_still(Sequence * seq, TStripElem * se)
        }
 }
 
+static void free_metastrip_imbufs(ListBase *seqbasep, int cfra, int chanshown)
+{
+       Sequence* seq_arr[MAXSEQ+1];
+       int i;
+       TStripElem* se = 0;
+
+       evaluate_seq_frame_gen(seq_arr, seqbasep, cfra);
+
+       for (i = 0; i < MAXSEQ; i++) {
+               if (!video_seq_is_rendered(seq_arr[i])) {
+                       continue;
+               }
+               se = give_tstripelem(seq_arr[i], cfra);
+               if (se) {
+                       if (se->ibuf) {
+                               IMB_freeImBuf(se->ibuf);
+
+                               se->ibuf= 0;
+                               se->ok= STRIPELEM_OK;
+                       }
+
+                       if (se->ibuf_comp) {
+                               IMB_freeImBuf(se->ibuf_comp);
+
+                               se->ibuf_comp = 0;
+                       }
+               }
+       }
+       
+}
 
 static TStripElem* do_build_seq_array_recursively(
        ListBase *seqbasep, int cfra, int chanshown);
@@ -1682,6 +1712,10 @@ static void do_build_seq_ibuf(Sequence * seq, TStripElem *se, int cfra,
                                use_limiter = TRUE;
                        }
                }
+               if (meta_se) {
+                       free_metastrip_imbufs(
+                               &seq->seqbase, seq->start + se->nr, 0);
+               }
 
                if (use_limiter) {
                        input_preprocess(seq, se, cfra);
index 5b6af61949f3b022a238638a1e9c0a4423e1d7c2..5f80f14d06963d41ec928d1c5ed845aee809d121 100644 (file)
@@ -228,8 +228,8 @@ void persptoetsen(unsigned short event)
        }
        else {
                /* Indicate that this view is not inverted.
-                * Don't do this for PADMINUS/PADPLUSKEY, though. (jobbe)*/
-               if (event != PADMINUS && event != PADPLUSKEY)
+                * Don't do this for PADMINUS/PADPLUSKEY/PAD5, though. (jobbe)*/
+               if (! ELEM3(event, PADMINUS, PADPLUSKEY, PAD5) )
                        G.vd->flag2 &= ~V3D_OPP_DIRECTION_NAME;
                
 
index f69218664ea44cdcf22180aa575b21e91080bd98..dcebf6b75578351cd5231cecd1fa2f44b05a3fa2 100644 (file)
@@ -1365,7 +1365,7 @@ static void createTransCurveVerts(TransInfo *t)
                                                tail++;
                                        }
                                        if(             propmode ||
-                                                       ((bezt->f1 & SELECT) && (G.f & G_HIDDENHANDLES)) ||
+                                                       ((bezt->f2 & SELECT) && (G.f & G_HIDDENHANDLES)) ||
                                                        ((bezt->f3 & SELECT) && (G.f & G_HIDDENHANDLES)==0)
                                          ) {
                                                VECCOPY(td->iloc, bezt->vec[2]);
@@ -4054,6 +4054,7 @@ void createTransData(TransInfo *t)
                t->flag |= T_POINTS;
        }
        else {
+               t->flag &= ~T_PROP_EDIT; /* no proportional edit in object mode */
                createTransObject(t);
                t->flag |= T_OBJECT;
        }
index 5c06aaea890be358e838a40330630542d67e3562..050360887b4d1f3a73d1ec0880d774b4805f2842 100644 (file)
@@ -158,7 +158,7 @@ static void protectflag_to_drawflags(short protectflag, short *drawflags)
 }
 
 /* for pose mode */
-static void stats_pose(View3D *v3d, bPoseChannel *pchan, float *normal, float *plane)
+static void stats_pose(View3D *v3d, bPoseChannel *pchan)
 {
        Bone *bone= pchan->bone;
        
@@ -166,9 +166,6 @@ static void stats_pose(View3D *v3d, bPoseChannel *pchan, float *normal, float *p
                if (bone->flag & BONE_TRANSFORM) {
                        calc_tw_center(pchan->pose_head);
                        protectflag_to_drawflags(pchan->protectflag, &v3d->twdrawflag);
-
-                       VecAddf(normal, normal, pchan->pose_mat[2]);
-                       VecAddf(plane, plane, pchan->pose_mat[1]);
                }
        }
 }
@@ -349,26 +346,24 @@ int calc_manipulator_stats(ScrArea *sa)
                }
        }
        else if(ob && (ob->flag & OB_POSEMODE)) {
-               bArmature *arm= ob->data;
+               bArmature *arm = ob->data;
                bPoseChannel *pchan;
                int mode;
                
                if((ob->lay & G.vd->lay)==0) return 0;
                
-               mode= Trans.mode;
-               Trans.mode= TFM_ROTATION;       // mislead counting bones... bah
+               mode = Trans.mode;
+               Trans.mode = TFM_ROTATION;      // mislead counting bones... bah
                
                /* count total, we use same method as transform will do */
                Trans.total= 0;
                count_bone_select(&Trans, arm, &arm->bonebase, 1);
-               totsel= Trans.total;
+               totsel = Trans.total;
                if(totsel) {
                        /* use channels to get stats */
                        for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-                               stats_pose(v3d, pchan, normal, plane);
+                               stats_pose(v3d, pchan);
                        }
-                       //VecMulf(normal, -1.0);
-                       VecMulf(plane, -1.0);
                        
                        VecMulf(G.scene->twcent, 1.0f/(float)totsel);   // centroid!
                        Mat4MulVecfl(ob->obmat, G.scene->twcent);
@@ -376,7 +371,7 @@ int calc_manipulator_stats(ScrArea *sa)
                        Mat4MulVecfl(ob->obmat, G.scene->twmax);
                }
                /* restore, mode can be TFM_INIT */
-               Trans.mode= mode;
+               Trans.mode = mode;
        }
        else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) {
                ;
@@ -433,7 +428,7 @@ int calc_manipulator_stats(ScrArea *sa)
                        break;
                        
                case V3D_MANIP_NORMAL:
-                       if(G.obedit) {
+                       if(G.obedit || ob->flag & OB_POSEMODE) {
                                float mat[3][3];
                                int type;
                                
@@ -479,34 +474,6 @@ int calc_manipulator_stats(ScrArea *sa)
                                }
                                break;
                        }
-                       /* pose mode is a bit weird, so keep it separated */
-                       else if (ob->flag & OB_POSEMODE)
-                       {
-                               strcpy(t->spacename, "normal");
-                               if(normal[0]!=0.0 || normal[1]!=0.0 || normal[2]!=0.0) {
-                                       float imat[3][3], mat[3][3];
-                                       
-                                       /* we need the transpose of the inverse for a normal... */
-                                       Mat3CpyMat4(imat, ob->obmat);
-                                       
-                                       Mat3Inv(mat, imat);
-                                       Mat3Transp(mat);
-                                       Mat3MulVecfl(mat, normal);
-                                       Mat3MulVecfl(mat, plane);
-
-                                       Normalize(normal);
-                                       if(0.0==Normalize(plane)) VECCOPY(plane, mat[1]);
-                                       
-                                       VECCOPY(mat[2], normal);
-                                       Crossf(mat[0], normal, plane);
-                                       Crossf(mat[1], mat[2], mat[0]);
-                                       
-                                       Mat4CpyMat3(v3d->twmat, mat);
-                                       Mat4Ortho(v3d->twmat);
-
-                                       break;
-                               }
-                       }
                        /* no break we define 'normal' as 'local' in Object mode */
                case V3D_MANIP_LOCAL:
                        strcpy(t->spacename, "local");
index 6696fcf95d660b8bd4c5399cf349ad5caf64a088..9c7a2f67b89561b9c08028959cdf95ae676f1122 100644 (file)
@@ -27,6 +27,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_armature_types.h"
+#include "DNA_action_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_listBase.h"
 #include "DNA_object_types.h"
@@ -68,11 +69,17 @@ void BIF_clearTransformOrientation(void)
 }
  
 void BIF_manageTransformOrientation(int confirm, int set) {
+       Object *ob = OBACT;
        int index = -1; 
        
        if (G.obedit) {
                if (G.obedit->type == OB_MESH)
                        index = manageMeshSpace(confirm, set);
+               else if (G.obedit->type == OB_ARMATURE)
+                       index = manageBoneSpace(confirm, set);
+       }
+       else if (ob && (ob->flag & OB_POSEMODE)) {
+                       index = manageBoneSpace(confirm, set);
        }
        else {
                index = manageObjectSpace(confirm, set);
@@ -122,6 +129,31 @@ int confirmSpace(int set, char text[])
        }
 }
 
+int manageBoneSpace(int confirm, int set) {
+       float mat[3][3];
+       float normal[3], plane[3];
+       char name[36] = "";
+       int index;
+
+       getTransformOrientation(normal, plane, 0);
+       
+       if (confirm == 0 && confirmSpace(set, "Bone") == 0) {
+               return -1;
+       }
+
+       if (createSpaceNormalTangent(mat, normal, plane) == 0) {
+               error("Cannot use zero-length bone");
+               return -1;
+       }
+
+       strcpy(name, "Bone");
+
+       /* Input name */
+       sbutton(name, 1, 35, "name: ");
+
+       index = addMatrixSpace(mat, name);
+       return index;
+}
 
 int manageMeshSpace(int confirm, int set) {
        float mat[3][3];
@@ -363,6 +395,29 @@ void applyTransformOrientation() {
        }
 }
 
+static int count_bone_select(bArmature *arm, ListBase *lb, int do_it) 
+{
+       Bone *bone;
+       int do_next;
+       int total = 0;
+       
+       for(bone= lb->first; bone; bone= bone->next) {
+               bone->flag &= ~BONE_TRANSFORM;
+               do_next = do_it;
+               if(do_it) {
+                       if(bone->layer & arm->layer) {
+                               if (bone->flag & BONE_SELECTED) {
+                                       bone->flag |= BONE_TRANSFORM;
+                                       total++;
+                                       do_next= 0;     // no transform on children if one parent bone is selected
+                               }
+                       }
+               }
+               total += count_bone_select(arm, &bone->childbase, do_next);
+       }
+       
+       return total;
+}
 
 int getTransformOrientation(float normal[3], float plane[3], int activeOnly)
 {
@@ -375,6 +430,14 @@ int getTransformOrientation(float normal[3], float plane[3], int activeOnly)
 
        if(G.obedit)
        {
+               float imat[3][3], mat[3][3];
+               
+               /* we need the transpose of the inverse for a normal... */
+               Mat3CpyMat4(imat, ob->obmat);
+               
+               Mat3Inv(mat, imat);
+               Mat3Transp(mat);
+
                ob= G.obedit;
 
                if(G.obedit->type==OB_MESH)
@@ -639,12 +702,48 @@ int getTransformOrientation(float normal[3], float plane[3], int activeOnly)
                        }
 
                }
-               
-               Mat4Mul3Vecfl(G.obedit->obmat, plane);
-               Mat4Mul3Vecfl(G.obedit->obmat, normal);
+
+               /* Vectors from edges don't need the special transpose inverse multiplication */
+               if (result == ORIENTATION_EDGE)
+               {
+                       Mat4Mul3Vecfl(ob->obmat, normal);
+                       Mat4Mul3Vecfl(ob->obmat, plane);
+               }
+               else
+               {
+                       Mat3MulVecfl(mat, normal);
+                       Mat3MulVecfl(mat, plane);
+               }
        }
        else if(ob && (ob->flag & OB_POSEMODE))
        {
+               bArmature *arm= ob->data;
+               bPoseChannel *pchan;
+               int totsel;
+               
+               totsel = count_bone_select(arm, &arm->bonebase, 1);
+               if(totsel) {
+                       float imat[3][3], mat[3][3];
+
+                       /* use channels to get stats */
+                       for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+                               if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
+                                       VecAddf(normal, normal, pchan->pose_mat[2]);
+                                       VecAddf(plane, plane, pchan->pose_mat[1]);
+                               }
+                       }
+                       VecMulf(plane, -1.0);
+                       
+                       /* we need the transpose of the inverse for a normal... */
+                       Mat3CpyMat4(imat, ob->obmat);
+                       
+                       Mat3Inv(mat, imat);
+                       Mat3Transp(mat);
+                       Mat3MulVecfl(mat, normal);
+                       Mat3MulVecfl(mat, plane);
+                       
+                       result = ORIENTATION_EDGE;
+               }
        }
        else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE))
        {
index 2904ca60a124bb6b63dd40c542009c523bacf519..1e45f2bf3e049c334a84f102e517a76945a7fe86 100644 (file)
@@ -1448,6 +1448,8 @@ void obmat_to_viewmat(Object *ob, short smooth)
        float bmat[4][4];
        float tmat[3][3];
 
+       G.vd->view= 0; /* dont show the grid */
+
        Mat4CpyMat4(bmat, ob->obmat);
        Mat4Ortho(bmat);
        Mat4Invert(G.vd->viewmat, bmat);
index a656c5e5523c0f00dfd46902c6fd7b604cc0488d..ffd66655069a076e89811f6506aa6c00b8f282a2 100644 (file)
@@ -125,6 +125,22 @@ void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
 
 }
 
+void KX_BlenderRenderTools::SetClientObject(void* obj)
+{
+       if (m_clientobject != obj)
+       {
+               if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling())
+               {
+                       glFrontFace(GL_CCW);
+               } else 
+               {
+                       glFrontFace(GL_CW);
+               }
+               m_clientobject = obj;
+               m_modified = true;
+       }
+}
+
 bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
 {
        double* const oglmatrix = (double* const) data;
index 662f5bd9af14383f6b0dad0ed673a1500df5b823..31eaa14d66b980aff754a45667d48cf2a0950b89 100644 (file)
@@ -105,6 +105,8 @@ public:
 
        virtual void Render2DFilters(RAS_ICanvas* canvas);
 
+       virtual void SetClientObject(void* obj);
+
 };
 
 #endif //__KX_BLENDERRENDERTOOLS
index edda7657ef950dd3c8fb6b3ba094e5042e049caa..885981a2898dd90de87411ac65ed953c25029f74 100644 (file)
@@ -462,6 +462,22 @@ int GPC_RenderTools::applyLights(int objectlayer)
 
 }
 
+void GPC_RenderTools::SetClientObject(void* obj)
+{
+       if (m_clientobject != obj)
+       {
+               if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling())
+               {
+                       glFrontFace(GL_CCW);
+               } else 
+               {
+                       glFrontFace(GL_CW);
+               }
+               m_clientobject = obj;
+               m_modified = true;
+       }
+}
+
 bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
 {
        double* const oglmatrix = (double* const) data;
index 9b86869af733cd13049ab1f0507d141cb2f8b0a6..ee0212da6438597509cb1b3483b118fafbacdac4 100644 (file)
@@ -153,6 +153,8 @@ public:
 
        virtual void Render2DFilters(RAS_ICanvas* canvas);
 
+       virtual void SetClientObject(void* obj);
+
 protected:
        /** 
         * Copied from KX_BlenderGL.cpp in KX_blenderhook
index 5fd5d2d54926fcf8c17a63e3a05c81bfaf9e2d54..dada47e2fa46a54185cc151e2a6c0123373b21e5 100644 (file)
@@ -77,6 +77,7 @@ KX_GameObject::KX_GameObject(
        m_layer(0),
        m_bSuspendDynamics(false),
        m_bUseObjectColor(false),
+       m_bIsNegativeScaling(false),
        m_bVisible(true),
        m_pPhysicsController1(NULL),
        m_pPhysicsEnvironment(NULL),
@@ -335,7 +336,7 @@ double*     KX_GameObject::GetOpenGLMatrix()
        trans.setBasis(GetSGNode()->GetWorldOrientation());
        
        MT_Vector3 scaling = GetSGNode()->GetWorldScaling();
-       
+       m_bIsNegativeScaling = ((scaling[0] < 0.0) ^ (scaling[1] < 0.0) ^ (scaling[2] < 0.0)) ? true : false;
        trans.scale(scaling[0], scaling[1], scaling[2]);
        trans.getValue(fl);
 
index 6e765978821e7a1c4d2231d5679d77dc9f796d79..3758651f53dee8f50609a6f93635b718f50e1f5d 100644 (file)
@@ -75,6 +75,7 @@ protected:
        
        bool                                                            m_bSuspendDynamics;
        bool                                                            m_bUseObjectColor;
+       bool                                                            m_bIsNegativeScaling;
        MT_Vector4                                                      m_objectColor;
 
        // Is this object set to be visible? Only useful for the
@@ -598,6 +599,14 @@ public:
                void
        );
                
+       /**
+        * Get the negative scaling state
+        */
+               bool
+       IsNegativeScaling(
+               void
+       ) { return m_bIsNegativeScaling; }
+
        /**
         * @section Logic bubbling methods.
         */
index 16e15653c826e44d66c1a499bd7cb9b3fb50e669..bcbf907741b1be74842a4cd65d0e21aa93990967 100644 (file)
@@ -146,6 +146,7 @@ public:
                int layer
        )=0;
 
+       virtual
                void    
        SetClientObject(
                void* obj
index 02e84f8a243d29edc64570441d5e5665a8347306..96ce220ae4d65af8e52e632d5e8b72079acca2c9 100644 (file)
@@ -325,6 +325,8 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
                while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode))
                        RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode);
        }
+       // to reset the eventual GL_CW mode
+       rendertools->SetClientObject(NULL);
 }