soc-2008-mxcurioni: merge with trunk - rev 15540
authorMaxime Curioni <maxime.curioni@gmail.com>
Sat, 12 Jul 2008 05:02:47 +0000 (05:02 +0000)
committerMaxime Curioni <maxime.curioni@gmail.com>
Sat, 12 Jul 2008 05:02:47 +0000 (05:02 +0000)
112 files changed:
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/moto/include/GEN_Map.h
projectfiles_vc7/blender/blenlib/BLI_blenlib.vcproj
source/blender/blenkernel/BKE_bmeshCustomData.h
source/blender/blenkernel/BKE_customdata.h
source/blender/blenkernel/intern/BME_Customdata.c
source/blender/blenkernel/intern/BME_conversions.c
source/blender/blenkernel/intern/BME_eulers.c
source/blender/blenkernel/intern/BME_structure.c
source/blender/blenkernel/intern/BME_tools.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenlib/BLI_mempool.h
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/BLI_mempool.c
source/blender/blenlib/intern/storage.c
source/blender/blenlib/intern/util.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/include/BDR_drawobject.h
source/blender/include/BIF_editarmature.h
source/blender/include/BSE_sequence.h
source/blender/makesdna/DNA_actuator_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/nodes/intern/CMP_nodes/CMP_gamma.c
source/blender/python/api2_2x/sceneSequence.c
source/blender/radiosity/intern/source/radrender.c
source/blender/render/intern/source/convertblender.c
source/blender/src/buttons_logic.c
source/blender/src/buttons_object.c
source/blender/src/buttons_scene.c
source/blender/src/buttons_shading.c
source/blender/src/drawarmature.c
source/blender/src/drawimage.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/editarmature.c
source/blender/src/editmesh_add.c
source/blender/src/editnla.c
source/blender/src/editsima.c
source/blender/src/edittime.c
source/blender/src/header_image.c
source/blender/src/header_view3d.c
source/blender/src/sequence.c
source/blender/src/space.c
source/blender/src/transform_conversions.c
source/blender/src/usiblender.c
source/blender/src/view.c
source/blender/src/vpaint.c
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/BL_MeshDeformer.cpp
source/gameengine/Converter/BL_MeshDeformer.h
source/gameengine/Converter/BL_ShapeDeformer.h
source/gameengine/Converter/BL_SkinDeformer.cpp
source/gameengine/Converter/BL_SkinDeformer.h
source/gameengine/Converter/BL_SkinMeshObject.cpp
source/gameengine/Converter/BL_SkinMeshObject.h
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Expressions/PyObjectPlus.h
source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
source/gameengine/GameLogic/SCA_IActuator.h
source/gameengine/GameLogic/SCA_IObject.cpp
source/gameengine/GameLogic/SCA_IObject.h
source/gameengine/GameLogic/SCA_ISensor.h
source/gameengine/Ketsji/BL_BlenderShader.cpp
source/gameengine/Ketsji/BL_BlenderShader.h
source/gameengine/Ketsji/BL_Material.cpp
source/gameengine/Ketsji/BL_Material.h
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Ketsji/KX_IPO_SGController.cpp
source/gameengine/Ketsji/KX_IPO_SGController.h
source/gameengine/Ketsji/KX_IpoActuator.cpp
source/gameengine/Ketsji/KX_IpoActuator.h
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_Light.h
source/gameengine/Ketsji/KX_ParentActuator.cpp
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/Ketsji/KX_TouchEventManager.cpp
source/gameengine/PyDoc/BL_ActionActuator.py
source/gameengine/Rasterizer/RAS_BucketManager.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
source/gameengine/Rasterizer/RAS_IRasterizer.h
source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
source/gameengine/Rasterizer/RAS_MaterialBucket.h
source/gameengine/Rasterizer/RAS_MeshObject.cpp
source/gameengine/Rasterizer/RAS_MeshObject.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h
source/gameengine/Rasterizer/RAS_TexVert.cpp
source/gameengine/Rasterizer/RAS_TexVert.h
source/gameengine/SceneGraph/SG_Controller.h
source/kernel/gen_system/GEN_HashedPtr.h
source/kernel/gen_system/GEN_Map.h
tools/Blender.py

index 82a76b3c7064e0e204249c6b942ef171f3fe2730..293f8fc1661d2230ec2f1ff109c5564da92d0ef6 100644 (file)
@@ -302,6 +302,15 @@ GHOST_TSuccess GHOST_SystemWin32::init()
 {
        GHOST_TSuccess success = GHOST_System::init();
 
+       /* Disable scaling on high DPI displays on Vista */
+       HMODULE user32 = ::LoadLibraryA("user32.dll");
+       typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)();
+       LPFNSETPROCESSDPIAWARE SetProcessDPIAware =
+               (LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware");
+       if (SetProcessDPIAware)
+               SetProcessDPIAware();
+       FreeLibrary(user32);
+
        // Determine whether this system has a high frequency performance counter. */
        m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq) == TRUE;
        if (m_hasPerformanceCounter) {
index db3335d6110f7003943331bcadd6b13e7125bbac..9f56924419ea32be776a65f4345e26d01a140841 100644 (file)
@@ -82,6 +82,24 @@ public:
         }
         return 0;
     }
+
+    Key* getKey(int index) {
+        int count=0;
+        for (int i=0;i<m_num_buckets;i++)
+        {
+            Entry* bucket = m_buckets[i];
+            while(bucket)
+            {
+                if (count==index)
+                {
+                    return &bucket->m_key;
+                }
+                bucket = bucket->m_next;
+                count++;
+            }
+        }
+        return 0;
+    }
     
     void clear() {
         for (int i = 0; i < m_num_buckets; ++i) {
index 34c195cf23d9d6f5d29c78046645141b2553011b..0dfbcaa55779e145e41aa2c9f6cba7914c07c4da 100644 (file)
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\intern\BLI_memarena.c">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\blender\blenlib\intern\BLI_mempool.c">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\intern\boxpack2d.c">
                        </File>
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\BLI_memarena.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\blender\blenlib\BLI_mempool.h">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\blender\blenlib\intern\BLI_scanfill.h">
                        </File>
index 423f75e532d582d84003f8e5a94e5288dc0f4571..4f5f2641f548d72596b136ab23048c03d10b5e6f 100644 (file)
@@ -38,7 +38,7 @@
 #ifndef BKE_BMESHCUSTOMDATA_H
 #define BKE_BMESHCUSTOMDATA_H
 
-struct BME_mempool;
+struct BLI_mempool;
 
 /*Custom Data Types and defines
        Eventual plan is to move almost everything to custom data and let caller
@@ -62,7 +62,7 @@ typedef struct BME_CustomDataLayer {
 
 typedef struct BME_CustomData {
        struct BME_CustomDataLayer *layers;     /*Custom Data Layers*/
-       struct BME_mempool *pool;                               /*pool for alloc of blocks*/
+       struct BLI_mempool *pool;                               /*pool for alloc of blocks*/
        int totlayer, totsize;          /*total layers and total size in bytes of each block*/
 } BME_CustomData;
 
index 81c2e4a4b946476d4452e921c0eb2675370b3f0c..e84c7d309566238be4b97cc1cbcff489e67538e0 100644 (file)
@@ -41,6 +41,7 @@ extern const CustomDataMask CD_MASK_MESH;
 extern const CustomDataMask CD_MASK_EDITMESH;
 extern const CustomDataMask CD_MASK_DERIVEDMESH;
 extern const CustomDataMask CD_MASK_BMESH;
+extern const CustomDataMask CD_MASK_FACECORNERS;
 
 /* for ORIGINDEX layer type, indicates no original index for this element */
 #define ORIGINDEX_NONE -1
@@ -264,4 +265,9 @@ void CustomData_set_layer_unique_name(struct CustomData *data, int index);
 /* for file reading compatibility, returns false if the layer was freed,
    only after this test passes, layer->data should be assigned */
 int CustomData_verify_versions(struct CustomData *data, int index);
+
+/*BMesh specific customdata stuff*/
+void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata);
+void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int total);
+void CustomData_bmesh_init_pool(struct CustomData *data, int allocsize);
 #endif
index 8b48efbdbd23b740fe49625a410a23aaa01db372..1fc8a4071dc8bf6b760e60e4b084ad367408fb34 100644 (file)
@@ -40,6 +40,7 @@
 #include "bmesh_private.h"
 #include <string.h>
 #include "MEM_guardedalloc.h"
+#include "BLI_mempool.h"
 
 /********************* Layer type information **********************/
 typedef struct BME_LayerTypeInfo {
@@ -83,7 +84,7 @@ void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc
        if(data->totlayer){
                /*alloc memory*/
                data->layers = MEM_callocN(sizeof(BME_CustomDataLayer)*data->totlayer, "BMesh Custom Data Layers");
-               data->pool = BME_mempool_create(data->totsize, initalloc, initalloc);
+               data->pool = BLI_mempool_create(data->totsize, initalloc, initalloc);
                /*initialize layer data*/
                for(i=0; i < BME_CD_NUMTYPES; i++){
                        if(init->layout[i]){
@@ -102,7 +103,7 @@ void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc
 
 void BME_CD_Free(BME_CustomData *data)
 {
-       if(data->pool) BME_mempool_destroy(data->pool);
+       if(data->pool) BLI_mempool_destroy(data->pool);
 }
 
 /*Block level ops*/
@@ -119,7 +120,7 @@ void BME_CD_free_block(BME_CustomData *data, void **block)
                        typeInfo->free((char*)*block + offset, 1, typeInfo->size);
                }
        }
-       BME_mempool_free(data->pool, *block);
+       BLI_mempool_free(data->pool, *block);
        *block = NULL;
 }
 
@@ -130,7 +131,7 @@ static void BME_CD_alloc_block(BME_CustomData *data, void **block)
        if (*block) BME_CD_free_block(data, block); //if we copy layers that have their own free functions like deformverts
        
        if (data->totsize > 0)
-               *block = BME_mempool_alloc(data->pool); 
+               *block = BLI_mempool_alloc(data->pool); 
        else
                *block = NULL;
 }
index 7952546de7c0590bd0279ce9f42f855df8c054b5..daf0de5b748e1e91eafe368dbc0f0909c648ace6 100644 (file)
 #include "bmesh_private.h"
 
 #include "BSE_edit.h"
-/*Converts an EditMesh to a BME_Mesh.*/
-static void bmesh_init_cdPool(CustomData *data, int allocsize){
-       if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize);
+
+/*merge these functions*/
+static void BME_DMcorners_to_loops(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f, int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i< numTex; i++){
+               texface = CustomData_get_layer_n(facedata, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+
+               texpoly->tpage = texface[index].tpage;
+               texpoly->flag = texface[index].flag;
+               texpoly->transp = texface[index].transp;
+               texpoly->mode = texface[index].mode;
+               texpoly->tile = texface[index].tile;
+               texpoly->unwrap = texface[index].unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       mloopuv->uv[0] = texface[index].uv[j][0];
+                       mloopuv->uv[1] = texface[index].uv[j][1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_get_layer_n(facedata, CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mloopcol->r = mcol[(index*4)+j].r;
+                       mloopcol->g = mcol[(index*4)+j].g;
+                       mloopcol->b = mcol[(index*4)+j].b;
+                       mloopcol->a = mcol[(index*4)+j].a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+
+static void BME_DMloops_to_corners(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f,int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i < numTex; i++){
+               texface = CustomData_get_layer_n(facedata, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+               
+               texface[index].tpage = texpoly->tpage;
+               texface[index].flag = texpoly->flag;
+               texface[index].transp = texpoly->transp;
+               texface[index].mode = texpoly->mode;
+               texface[index].tile = texpoly->tile;
+               texface[index].unwrap = texpoly->unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       texface[index].uv[j][0] = mloopuv->uv[0];
+                       texface[index].uv[j][1] = mloopuv->uv[1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+
+       }
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_get_layer_n(facedata,CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mcol[(index*4) + j].r = mloopcol->r;
+                       mcol[(index*4) + j].g = mloopcol->g;
+                       mcol[(index*4) + j].b = mloopcol->b;
+                       mcol[(index*4) + j].a = mloopcol->a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
 }
 
+
+static void BME_corners_to_loops(BME_Mesh *bm, CustomData *facedata, void *face_block, BME_Poly *f,int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i < numTex; i++){
+               texface = CustomData_em_get_n(facedata, face_block, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+               
+               texpoly->tpage = texface->tpage;
+               texpoly->flag = texface->flag;
+               texpoly->transp = texface->transp;
+               texpoly->mode = texface->mode;
+               texpoly->tile = texface->tile;
+               texpoly->unwrap = texface->unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       mloopuv->uv[0] = texface->uv[j][0];
+                       mloopuv->uv[1] = texface->uv[j][1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+
+       }
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_em_get_n(facedata, face_block, CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mloopcol->r = mcol[j].r;
+                       mloopcol->g = mcol[j].g;
+                       mloopcol->b = mcol[j].b;
+                       mloopcol->a = mcol[j].a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+
+static void BME_loops_to_corners(BME_Mesh *bm, CustomData *facedata, void *face_block, BME_Poly *f,int numCol, int numTex){
+       int i, j;
+       BME_Loop *l;
+       MTFace *texface;
+       MTexPoly *texpoly;
+       MCol *mcol;
+       MLoopCol *mloopcol;
+       MLoopUV *mloopuv;
+
+       for(i=0; i < numTex; i++){
+               texface = CustomData_em_get_n(facedata, face_block, CD_MTFACE, i);
+               texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+               
+               texface->tpage = texpoly->tpage;
+               texface->flag = texpoly->flag;
+               texface->transp = texpoly->transp;
+               texface->mode = texpoly->mode;
+               texface->tile = texpoly->tile;
+               texface->unwrap = texpoly->unwrap;
+
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+                       texface->uv[j][0] = mloopuv->uv[0];
+                       texface->uv[j][1] = mloopuv->uv[1];
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+
+       }
+       for(i=0; i < numCol; i++){
+               mcol = CustomData_em_get_n(facedata, face_block, CD_MCOL, i);
+               j = 0;
+               l = f->loopbase;
+               do{
+                       mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+                       mcol[j].r = mloopcol->r;
+                       mcol[j].g = mloopcol->g;
+                       mcol[j].b = mloopcol->b;
+                       mcol[j].a = mloopcol->a;
+                       j++;
+                       l = l->next;
+               }while(l!=f->loopbase);
+       }
+}
+/*move the EditMesh conversion functions to editmesh_tools.c*/
 BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
        BME_Mesh *bm;
-       int allocsize[4] = {512,512,2048,512};
+       int allocsize[4] = {512,512,2048,512}, numTex, numCol;
        BME_Vert *v1, *v2;
        BME_Edge *e, *edar[4];
        BME_Poly *f;
@@ -74,8 +260,21 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
        int len;
        bm = BME_make_mesh(allocsize);
 
+       /*copy custom data layout*/
        CustomData_copy(&em->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
-       bmesh_init_cdPool(&bm->vdata, allocsize[0]);
+       CustomData_copy(&em->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&em->fdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+
+       /*copy face corner data*/
+       CustomData_to_bmeshpoly(&em->fdata, &bm->pdata, &bm->ldata);
+       /*initialize memory pools*/
+       CustomData_bmesh_init_pool(&bm->vdata, allocsize[0]);
+       CustomData_bmesh_init_pool(&bm->edata, allocsize[1]);
+       CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]);
+       CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]);
+       /*needed later*/
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
 
        BME_model_begin(bm);
        /*add verts*/
@@ -86,7 +285,6 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
                v1->flag = eve->f;
                v1->h = eve->h;
                v1->bweight = eve->bweight;
-
                /*Copy Custom Data*/
                CustomData_bmesh_copy_data(&em->vdata, &bm->vdata, eve->data, &v1->data);
                eve->tmp.v = (EditVert*)v1;
@@ -106,15 +304,10 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
                if(eed->seam) e->flag |= ME_SEAM;
                if(eed->h & EM_FGON) e->flag |= ME_FGON;
                if(eed->h & 1) e->flag |= ME_HIDE;
-
-               /* link the edges for face construction;
-                * kind of a dangerous thing - remember to cast back to BME_Edge before using! */
-               /*Copy CustomData*/
-
                eed->tmp.e = (EditEdge*)e;
+               CustomData_bmesh_copy_data(&em->edata, &bm->edata, eed->data, &e->data);
                eed = eed->next;
        }
-
        /*add faces.*/
        efa= em->faces.first;
        while(efa) {
@@ -143,12 +336,13 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
                        if(efa->f & 1) f->flag |= ME_FACE_SEL;
                        else f->flag &= ~ME_FACE_SEL;
                }
+               CustomData_bmesh_copy_data(&em->fdata, &bm->pdata, efa->data, &f->data);
+               BME_corners_to_loops(bm, &em->fdata, efa->data, f,numCol,numTex);
                efa = efa->next;
        }
        BME_model_end(bm);
        return bm;
 }
-
 /* adds the geometry in the bmesh to G.editMesh (does not free G.editMesh)
  * if td != NULL, the transdata will be mapped to the EditVert's co */
 EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
@@ -163,7 +357,7 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
        EditEdge *eed;
        EditFace *efa;
 
-       int totvert, len, i;
+       int totvert, len, i, numTex, numCol;
 
        em = G.editMesh;
 
@@ -171,6 +365,13 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
 
 
        CustomData_copy(&bm->vdata, &em->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm->edata, &em->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&bm->pdata, &em->fdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_from_bmeshpoly(&em->fdata, &bm->pdata, &bm->ldata,0);
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
+
        /* convert to EditMesh */
        /* make editverts */
        totvert = BLI_countlist(&(bm->verts));
@@ -202,6 +403,8 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                        if(e->flag & ME_HIDE) eed->h |= 1;
                        if(G.scene->selectmode==SCE_SELECT_EDGE) 
                                EM_select_edge(eed, eed->f & SELECT);
+               
+                       CustomData_em_copy_data(&bm->edata, &em->edata, e->data, &eed->data);
                }
        }
 
@@ -228,6 +431,8 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                        if(f->flag & ME_HIDE) efa->h= 1;
                        if((G.f & G_FACESELECT) && (efa->f & SELECT))
                                EM_select_face(efa, 1); /* flush down */
+                       CustomData_em_copy_data(&bm->pdata, &em->fdata, f->data, &efa->data);
+                       BME_loops_to_corners(bm, &em->fdata, efa->data, f,numCol,numTex);
                }
        }
 
@@ -248,7 +453,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
        MVert *mvert, *mv;
        MEdge *medge, *me;
        MFace *mface, *mf;
-       int totface,totedge,totvert,i,len;
+       int totface,totedge,totvert,i,len, numTex, numCol;
        BME_Vert *v1=NULL,*v2=NULL, **vert_array;
        BME_Edge *e=NULL;
        BME_Poly *f=NULL;
@@ -256,6 +461,22 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
        EdgeHash *edge_hash = BLI_edgehash_new();
 
        bm = BME_make_mesh(allocsize);
+       /*copy custom data layout*/
+       CustomData_copy(&dm->vertData, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&dm->edgeData, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
+       CustomData_copy(&dm->faceData, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+
+       /*copy face corner data*/
+       CustomData_to_bmeshpoly(&dm->faceData, &bm->pdata, &bm->ldata);
+       /*initialize memory pools*/
+       CustomData_bmesh_init_pool(&bm->vdata, allocsize[0]);
+       CustomData_bmesh_init_pool(&bm->edata, allocsize[1]);
+       CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]);
+       CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]);
+       /*needed later*/
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
        totvert = dm->getNumVerts(dm);
        totedge = dm->getNumEdges(dm);
        totface = dm->getNumFaces(dm);
@@ -272,6 +493,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
                vert_array[i] = v1;
                v1->flag = mv->flag;
                v1->bweight = mv->bweight/255.0f;
+               CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v1->data);
        }
        /*add edges*/
        for(i=0,me = medge; i < totedge;i++,me++){
@@ -282,6 +504,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
                e->bweight = me->bweight/255.0f;
                e->flag = (unsigned char)me->flag;
                BLI_edgehash_insert(edge_hash,me->v1,me->v2,e);
+               CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->data);
        }
        /*add faces.*/
        for(i=0,mf = mface; i < totface;i++,mf++){
@@ -305,6 +528,8 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
                f = BME_MF(bm,v1,v2,edar,len);
                f->mat_nr = mf->mat_nr;
                f->flag = mf->flag;
+               CustomData_to_bmesh_block(&dm->faceData,&bm->pdata,i,&f->data);
+               BME_DMcorners_to_loops(bm, &dm->faceData,i,f, numCol,numTex);
        }
        
        BME_model_end(bm);
@@ -318,7 +543,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
        MFace *mface, *mf;
        MEdge *medge, *me;
        MVert *mvert, *mv;
-       int totface,totedge,totvert,i,bmeshok,len;
+       int totface,totedge,totvert,i,bmeshok,len, numTex, numCol;
 
        BME_Vert *v1=NULL;
        BME_Edge *e=NULL, *oe=NULL;
@@ -354,12 +579,21 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
        
        /*convert back to mesh*/
        result = CDDM_from_template(dm,totvert,totedge,totface);
+       CustomData_merge(&bm->vdata, &result->vertData, CD_MASK_BMESH, CD_CALLOC, totvert);
+       CustomData_merge(&bm->edata, &result->edgeData, CD_MASK_BMESH, CD_CALLOC, totedge);
+       CustomData_merge(&bm->pdata, &result->faceData, CD_MASK_BMESH, CD_CALLOC, totface);
+       CustomData_from_bmeshpoly(&result->faceData, &bm->pdata, &bm->ldata,totface);
+       numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
+       numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
+
+
        /*Make Verts*/
        mvert = CDDM_get_verts(result);
        for(i=0,v1=bm->verts.first,mv=mvert;v1;v1=v1->next,i++,mv++){
                VECCOPY(mv->co,v1->co);
                mv->flag = (unsigned char)v1->flag;
                mv->bweight = (char)(255.0*v1->bweight);
+               CustomData_from_bmesh_block(&bm->vdata, &result->vertData, &v1->data, i);
        }
        medge = CDDM_get_edges(result);
        i=0;
@@ -377,6 +611,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
                        me->crease = (char)(255.0*e->crease);
                        me->bweight = (char)(255.0*e->bweight);
                        me->flag = e->flag;
+                       CustomData_from_bmesh_block(&bm->edata, &result->edgeData, &e->data, i);
                        me++;
                        i++;
                }
@@ -398,9 +633,11 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
                                if(mf->v3 == 0 || (len == 4 && mf->v4 == 0)){
                                        test_index_face(mf, NULL, i, len);
                                }
-                               i++;
                                mf->mat_nr = (unsigned char)f->mat_nr;
                                mf->flag = (unsigned char)f->flag;
+                               CustomData_from_bmesh_block(&bm->pdata, &result->faceData, &f->data, i);
+                               BME_DMloops_to_corners(bm, &result->faceData, i, f,numCol,numTex);
+                               i++;
                        }
                }
        }
index 3403f5829fe5f2ffd1326dcf1e9fef73fdaab6a7..801e0b8bdec9ff97cdf3115eb4228f890e9fdf05 100644 (file)
@@ -39,6 +39,7 @@
 #include "DNA_mesh_types.h"
 
 #include "BKE_utildefines.h"
+#include "BKE_customdata.h"
 #include "BKE_bmesh.h"
 
 #include "BLI_blenlib.h"
@@ -618,8 +619,8 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo
        BME_disk_append_edge(e, v2);
        
        f2 = BME_addpolylist(bm,f);
-       f1loop = BME_create_loop(bm,v2,e,f,NULL);
-       f2loop = BME_create_loop(bm,v1,e,f2,NULL);
+       f1loop = BME_create_loop(bm,v2,e,f,v2loop);
+       f2loop = BME_create_loop(bm,v1,e,f2,v1loop);
        
        f1loop->prev = v2loop->prev;
        f2loop->prev = v1loop->prev;
@@ -663,16 +664,16 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo
  *     Takes a an edge and pointer to one of its vertices and collapses
  *     the edge on that vertex.
  *     
- *     Before:             OE      KE
+ *     Before:    OE      KE
  *                      ------- -------
  *               |     ||      |
- *                             OV     KV      TV
+ *             OV     KV      TV
  *
  *
  *   After:             OE      
  *                      ---------------
  *               |             |
- *                             OV             TV
+ *             OV             TV
  *
  *
  *     Restrictions:
@@ -723,6 +724,8 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
                        /*remove ke from tv's disk cycle*/
                        BME_disk_remove_edge(ke, tv);
                
+                       
+
                        /*deal with radial cycle of ke*/
                        if(ke->loop){
                                /*first step, fix the neighboring loops of all loops in ke's radial cycle*/
@@ -763,6 +766,7 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
                                
                        }
                        
+
                        /*Validate disk cycles*/
                        diskbase = BME_disk_getpointer(ov->edge,ov);
                        edok = BME_cycle_validate(valance1, diskbase);
index 92ef9e3e03c7a205f7b6b2acc8c728480368f820..ca27f5efd1058831cf2dd61b99346229f1f8db47 100644 (file)
@@ -41,7 +41,6 @@
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"
 #include "BLI_ghash.h"
-
 /**
  *     MISC utility functions.
  *
index 916e6bee59f8e0014fcf9f7b701c7702a2d2f79f..90259031e5caa3e42e22ba9ef9ed75a64e5d336e 100644 (file)
@@ -215,10 +215,42 @@ static void BME_data_interp_from_verts(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2,
                src[1]= v2->data;
                w[0] = 1.0f-fac;
                w[1] = fac;
-               CustomData_em_interp(&bm->vdata, src, w, NULL, 2, v->data);
+               CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->data);
        }
 }
 
+
+static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Vert *v, BME_Edge *e1, float fac){
+       void *src[2];
+       float w[2];
+       BME_Loop *l=NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL;
+       
+       w[0] = 1.0f - fac;
+       w[1] = fac;
+
+       if(!e1->loop) return;
+       l = e1->loop;
+       do{
+               if(l->v == v1){ 
+                       v1loop = l;
+                       vloop = v1loop->next;
+                       v2loop = vloop->next;
+               }else if(l->v == v){
+                       v1loop = l->next;
+                       vloop = l;
+                       v2loop = l->prev;
+                       
+               }
+
+               src[0] = v1loop->data;
+               src[1] = v2loop->data;                                  
+
+               CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->data);                               
+               l = l->radial.next->data;
+       }while(l!=e1->loop);
+}
+
+
 /* a wrapper for BME_SEMV that transfers element flags */ /*add custom data interpolation in here!*/
 static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge **ne, float percent) {
        BME_Vert *nv, *v2;
@@ -238,9 +270,37 @@ static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge
                (*ne)->crease = e->crease;
                (*ne)->bweight = e->bweight;
        }
+       /*v->nv->v2*/
+       BME_data_facevert_edgesplit(bm,v2, v, nv, e, 0.75);     
        return nv;
 }
 
+static void BME_collapse_vert(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv, float fac){
+       void *src[2];
+       float w[2];
+       BME_Loop *l=NULL, *kvloop=NULL, *tvloop=NULL;
+       BME_Vert *tv = BME_edge_getothervert(ke,kv);
+
+       w[0] = 1.0f - fac;
+       w[1] = fac;
+
+       if(ke->loop){
+               l = ke->loop;
+               do{
+                       if(l->v == tv && l->next->v == kv){
+                               tvloop = l;
+                               kvloop = l->next;
+
+                               src[0] = kvloop->data;
+                               src[1] = tvloop->data;
+                               CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, kvloop->data);                                                              
+                       }
+                       l=l->radial.next->data;
+               }while(l!=ke->loop);
+       }
+       BME_JEKV(bm,ke,kv);
+}
+
 
 
 static int BME_bevel_is_split_vert(BME_Loop *l) {
@@ -367,6 +427,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
                ov = BME_edge_getothervert(e1,v);
                sv = BME_split_edge(bm,v,e1,&ne,0);
                //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/
+               //BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
+               //BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
                BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
                sv->tflag1 |= BME_BEVEL_BEVEL;
                ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
@@ -408,6 +470,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
                        ov = BME_edge_getothervert(l->e,v);
                        sv = BME_split_edge(bm,v,l->e,&ne,0);
                        //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/
+                       //BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
+                       //BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
                        BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
                        sv->tflag1 |= BME_BEVEL_BEVEL;
                        ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
@@ -586,12 +650,15 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti
                if (kl->v == kv) {
                        BME_split_face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
                        BME_JFKE(bm,((BME_Loop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
+                       
                }
                else {
                        BME_split_face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e);
                        BME_JFKE(bm,((BME_Loop*)kl->next->radial.next->data)->f,kl->f,kl->next->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
                }
                l = l->prev;
        }
@@ -620,12 +687,14 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti
                if (kl->v == kv) {
                        BME_split_face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
                        BME_JFKE(bm,((BME_Loop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
                }
                else {
                        BME_split_face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e);
                        BME_JFKE(bm,((BME_Loop*)kl->next->radial.next->data)->f,kl->f,kl->next->e);
-                       BME_JEKV(bm,kl->e,kv);
+                       BME_collapse_vert(bm, kl->e, kv, 1.0);
+                       //BME_JEKV(bm,kl->e,kv);
                }
        }
 
@@ -1092,7 +1161,8 @@ static void bmesh_dissolve_disk(BME_Mesh *bm, BME_Vert *v){
                                e = BME_disk_nextedge(e,v);
                        }while(e != v->edge);
                }
-               BME_JEKV(bm,v->edge,v);
+               BME_collapse_vert(bm, v->edge, v, 1.0);
+               //BME_JEKV(bm,v->edge,v);
        }
 }
 static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, int defgrp_index, BME_TransData_Head *td) {
index 3040566065818b7c1d6d68f04e8012048986f126..4d3f9143b851699cb13e45f61795e768542895d7 100644 (file)
@@ -1052,7 +1052,7 @@ void emDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
 
        /* store vertex indices in tmp union */
        for(ev = em->verts.first, i = 0; ev; ev = ev->next, ++i)
-               ev->tmp.l = (long) i++;
+               ev->tmp.l = (long) i;
 
        for( ; ee; ee = ee->next, ++edge_r) {
                edge_r->crease = (unsigned char) (ee->crease*255.0f);
index 4880a246e1cb387315b969d10506caffcd25c638..501293ecd814970d8ddc9a4e2a64cd4edc08a439 100644 (file)
@@ -360,8 +360,80 @@ static void layerDefault_origspace_face(void *data, int count)
 }
 /* --------- */
 
+static void layerDefault_mloopcol(void *data, int count)
+{
+       static MLoopCol default_mloopcol = {255,255,255,255};
+       MLoopCol *mlcol = (MLoopCol*)data;
+       int i;
+       for(i = 0; i < count; i++)
+               mlcol[i] = default_mloopcol;
+
+}
+
+static void layerInterp_mloopcol(void **sources, float *weights,
+                               float *sub_weights, int count, void *dest)
+{
+       MLoopCol *mc = dest;
+       int i;
+       float *sub_weight;
+       struct {
+               float a;
+               float r;
+               float g;
+               float b;
+       } col;
+       col.a = col.r = col.g = col.b = 0;
 
+       sub_weight = sub_weights;
+       for(i = 0; i < count; ++i){
+               float weight = weights ? weights[i] : 1;
+               MLoopCol *src = sources[i];
+               if(sub_weights){
+                       col.a += src->a * (*sub_weight) * weight;
+                       col.r += src->r * (*sub_weight) * weight;
+                       col.g += src->g * (*sub_weight) * weight;
+                       col.b += src->b * (*sub_weight) * weight;
+                       sub_weight++;           
+               } else {
+                       col.a += src->a * weight;
+                       col.r += src->r * weight;
+                       col.g += src->g * weight;
+                       col.b += src->b * weight;
+               }
+       }
+       mc->a = (int)col.a;
+       mc->r = (int)col.r;
+       mc->g = (int)col.g;
+       mc->b = (int)col.b;
+}
+static void layerInterp_mloopuv(void **sources, float *weights,
+                               float *sub_weights, int count, void *dest)
+{
+       MLoopUV *mluv = dest;
+       int i;
+       float *sub_weight;
+       struct {
+               float u;
+               float v;
+       }uv;
+       uv.u = uv.v = 0.0;
 
+       sub_weight = sub_weights;
+       for(i = 0; i < count; ++i){
+               float weight = weights ? weights[i] : 1;
+               MLoopUV *src = sources[i];
+               if(sub_weights){
+                       uv.u += src->uv[0] * (*sub_weight) * weight;
+                       uv.v += src->uv[1] * (*sub_weight) * weight;
+                       sub_weight++;           
+               } else {
+                       uv.u += src->uv[0] * weight;
+                       uv.v += src->uv[1] * weight;
+               }
+       }
+       mluv->uv[0] = uv.u;
+       mluv->uv[1] = uv.v;
+}
 
 static void layerInterp_mcol(void **sources, float *weights,
                              float *sub_weights, int count, void *dest)
@@ -433,6 +505,8 @@ static void layerDefault_mcol(void *data, int count)
                mcol[i] = default_mcol;
 }
 
+
+
 const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL,
@@ -457,8 +531,8 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
         layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
        {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        {sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL},
-       {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, NULL, NULL, NULL},
-       {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, NULL, NULL, NULL
+       {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL},
+       {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol
 };
 
 const char *LAYERTYPENAMES[CD_NUMTYPES] = {
@@ -480,7 +554,11 @@ const CustomDataMask CD_MASK_DERIVEDMESH =
        CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
        CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO;
 const CustomDataMask CD_MASK_BMESH = 
-       CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL;
+       CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR;
+const CustomDataMask CD_MASK_FACECORNERS =
+       CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
+       CD_MASK_MLOOPCOL;
+
 
 static const LayerTypeInfo *layerType_getInfo(int type)
 {
@@ -1456,6 +1534,36 @@ void CustomData_from_em_block(const CustomData *source, CustomData *dest,
 }
 
 /*Bmesh functions*/
+/*needed to convert to/from different face reps*/
+void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata)
+{
+       int i;
+       for(i=0; i < fdata->totlayer; i++){
+               if(fdata->layers[i].type == CD_MTFACE){
+                       CustomData_add_layer(pdata, CD_MTEXPOLY, CD_CALLOC, &(fdata->layers[i].name), 0);
+                       CustomData_add_layer(ldata, CD_MLOOPUV, CD_CALLOC, &(fdata->layers[i].name), 0);
+               }
+               else if(fdata->layers[i].type == CD_MCOL)
+                       CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), 0);
+       }               
+}
+void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){
+       int i;
+       for(i=0; i < pdata->totlayer; i++){
+               if(pdata->layers[i].type == CD_MTEXPOLY)
+                       CustomData_add_layer(fdata, CD_MTFACE, CD_CALLOC, &(pdata->layers[i].name), total);
+       }
+       for(i=0; i < ldata->totlayer; i++){
+               if(ldata->layers[i].type == CD_MLOOPCOL)
+                       CustomData_add_layer(fdata, CD_MCOL, CD_CALLOC, &(ldata->layers[i].name), total);
+       }
+}
+
+
+void CustomData_bmesh_init_pool(CustomData *data, int allocsize){
+       if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize);
+}
+
 void CustomData_bmesh_free_block(CustomData *data, void **block)
 {
     const LayerTypeInfo *typeInfo;
@@ -1484,7 +1592,7 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
                CustomData_bmesh_free_block(data, block);
 
        if (data->totsize > 0)
-               *block = BLI_mempool_alloc(data->pool);
+               *block = BLI_mempool_calloc(data->pool);
        else
                *block = NULL;
 }
@@ -1601,7 +1709,6 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
        for(i = 0; i < data->totlayer; ++i) {
                CustomDataLayer *layer = &data->layers[i];
                const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
-
                if(typeInfo->interp) {
                        for(j = 0; j < count; ++j)
                                sources[j] = (char *)src_blocks[j] + layer->offset;
index 7c50b4096939d92fd810bd2b90fe9c241ed71745..c3dddf06e7c0df668276d404ef1f14323dfcb6a8 100644 (file)
@@ -224,48 +224,50 @@ void flag_all_listbases_ids(short flag, short value)
 /* note: MAX_LIBARRAY define should match this code */
 int set_listbasepointers(Main *main, ListBase **lb)
 {
+       int a = 0;
+
        /* BACKWARDS! also watch order of free-ing! (mesh<->mat) */
 
-       lb[0]= &(main->ipo);
-       lb[1]= &(main->key);
-       lb[2]= &(main->image);
-       lb[3]= &(main->tex);
-       lb[4]= &(main->mat);
-       lb[5]= &(main->vfont);
+       lb[a++]= &(main->ipo);
+       lb[a++]= &(main->key);
+       lb[a++]= &(main->nodetree);
+       lb[a++]= &(main->image);
+       lb[a++]= &(main->tex);
+       lb[a++]= &(main->mat);
+       lb[a++]= &(main->vfont);
        
        /* Important!: When adding a new object type,
         * the specific data should be inserted here 
         */
 
-       lb[6]= &(main->armature);
-       lb[7]= &(main->action);
+       lb[a++]= &(main->armature);
+       lb[a++]= &(main->action);
 
-       lb[8]= &(main->mesh);
-       lb[9]= &(main->curve);
-       lb[10]= &(main->mball);
+       lb[a++]= &(main->mesh);
+       lb[a++]= &(main->curve);
+       lb[a++]= &(main->mball);
 
-       lb[11]= &(main->wave);
-       lb[12]= &(main->latt);
-       lb[13]= &(main->lamp);
-       lb[14]= &(main->camera);
+       lb[a++]= &(main->wave);
+       lb[a++]= &(main->latt);
+       lb[a++]= &(main->lamp);
+       lb[a++]= &(main->camera);
        
-       lb[15]= &(main->text);
-       lb[16]= &(main->sound);
-       lb[17]= &(main->group);
-       lb[18]= &(main->nodetree);
-       lb[19]= &(main->brush);
-       lb[20]= &(main->script);
-       lb[21]= &(main->particle);
+       lb[a++]= &(main->text);
+       lb[a++]= &(main->sound);
+       lb[a++]= &(main->group);
+       lb[a++]= &(main->brush);
+       lb[a++]= &(main->script);
+       lb[a++]= &(main->particle);
        
-       lb[22]= &(main->world);
-       lb[23]= &(main->screen);
-       lb[24]= &(main->object);
-       lb[25]= &(main->scene);
-       lb[26]= &(main->library);
+       lb[a++]= &(main->world);
+       lb[a++]= &(main->screen);
+       lb[a++]= &(main->object);
+       lb[a++]= &(main->scene);
+       lb[a++]= &(main->library);
        
-       lb[27]= NULL;
+       lb[a]= NULL;
 
-       return 27;
+       return a;
 }
 
 /* *********** ALLOC AND FREE *****************
index a0841bb9f03907ed41d78049b95384c486dc5444..f13f8ef0298c7ccc3029e38fb43d42e36cf23895 100644 (file)
@@ -4920,7 +4920,7 @@ static void waveModifier_deformVertsEM(
 
        if(!wmd->texture && !wmd->defgrp_name[0] && !(wmd->flag & MOD_WAVE_NORM))
                dm = derivedData;
-       else if(derivedData) dm = derivedData;
+       else if(derivedData) dm = CDDM_copy(derivedData);
        else dm = CDDM_from_editmesh(editData, ob->data);
 
        if(wmd->flag & MOD_WAVE_NORM) {
index 18fca5439efe4acea0a80505f1c43040601f7dca..24a3d348ae7ba6e934763da40feb05619b37bf44 100644 (file)
@@ -1371,7 +1371,7 @@ void psys_particle_on_shape(int distr, int index, float *fuv, float *vec, float
 /************************************************/
 void psys_particle_on_emitter(Object *ob, ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor){
        if(psmd){
-               if(psmd->psys->part->distr==PART_DISTR_GRID){
+               if(psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT){
                        if(vec){
                                VECCOPY(vec,fuv);
                        }
index 458171cc2329cd668d67df44d67bf2bff286dc66..f70648965f413a5b9474f12cc2ae1150f1ee8c90 100644 (file)
@@ -168,7 +168,7 @@ static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart)
        int i, totpart, totsaved = 0;
 
        if(new_totpart<0) {
-               if(psys->part->distr==PART_DISTR_GRID) {
+               if(psys->part->distr==PART_DISTR_GRID  && psys->part->from != PART_FROM_VERT) {
                        totpart= psys->part->grid_res;
                        totpart*=totpart*totpart;
                }
@@ -1056,7 +1056,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
                dm= CDDM_from_mesh((Mesh*)ob->data, ob);
 
                /* special handling of grid distribution */
-               if(part->distr==PART_DISTR_GRID){
+               if(part->distr==PART_DISTR_GRID && from != PART_FROM_VERT){
                        distribute_particles_in_grid(dm,psys);
                        dm->release(dm);
                        return 0;
@@ -1600,7 +1600,7 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps
 
        NormalQuat(pa->r_rot);
 
-       if(part->distr!=PART_DISTR_GRID){
+       if(part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){
                /* any unique random number will do (r_ave[0]) */
                if(ptex.exist < 0.5*(1.0+pa->r_ave[0]))
                        pa->flag |= PARS_UNEXIST;
@@ -4515,7 +4515,7 @@ void psys_changed_type(ParticleSystem *psys)
        if(part->from == PART_FROM_PARTICLE) {
                if(part->type != PART_REACTOR)
                        part->from = PART_FROM_FACE;
-               if(part->distr == PART_DISTR_GRID)
+               if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT)
                        part->distr = PART_DISTR_JIT;
        }
 
@@ -4710,7 +4710,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
        oldtotpart = psys->totpart;
        oldtotchild = psys->totchild;
 
-       if(part->distr == PART_DISTR_GRID)
+       if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT)
                totpart = part->grid_res*part->grid_res*part->grid_res;
        else
                totpart = psys->part->totpart;
index 57ecffbb79649b20d4bf062178a5219a69cce79f..43805959e620f2a5d456c79d14dba472c5f514f9 100644 (file)
@@ -459,9 +459,10 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
        PTCacheID pid;
        ParticleSystem *psys;
        ModifierData *md;
-       int reset;
+       int reset, skip;
 
        reset= 0;
+       skip= 0;
 
        if(ob->soft) {
                BKE_ptcache_id_from_softbody(&pid, ob, ob->soft);
@@ -469,11 +470,18 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
        }
 
        for(psys=ob->particlesystem.first; psys; psys=psys->next) {
-               BKE_ptcache_id_from_particles(&pid, ob, psys);
-               reset |= BKE_ptcache_id_reset(&pid, mode);
-
+               /* Baked softbody hair has to be checked first, because we don't want to reset */
+               /* particles or softbody in that case -jahka */
                if(psys->soft) {
                        BKE_ptcache_id_from_softbody(&pid, ob, psys->soft);
+                       if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) 
+                               reset |= BKE_ptcache_id_reset(&pid, mode);
+                       else
+                               skip = 1;
+               }
+
+               if(skip == 0) {
+                       BKE_ptcache_id_from_particles(&pid, ob, psys);
                        reset |= BKE_ptcache_id_reset(&pid, mode);
                }
        }
index a706e5f387475c899833f873c533b20cf5a0aa9d..8b31459dd382e02df735f4fa25f97390dc0294e5 100644 (file)
@@ -36,7 +36,9 @@ typedef struct BLI_mempool BLI_mempool;
 
 BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk);
 void *BLI_mempool_alloc(BLI_mempool *pool);
+void *BLI_mempool_calloc(BLI_mempool *pool);
 void BLI_mempool_free(BLI_mempool *pool, void *addr);
 void BLI_mempool_destroy(BLI_mempool *pool);
 
-#endif
\ No newline at end of file
+
+#endif
index a85883f65728a2000f476db0153bc48978e7cd67..a97b9ca6672bace8f7887ff6d3bfb3a9950615a4 100644 (file)
@@ -523,6 +523,7 @@ static void bvh_div_nodes(BVHTree *tree, BVHNode *node, int start, int end, char
        return;
 }
 
+#if 0
 static void verify_tree(BVHTree *tree)
 {
        int i, j, check = 0;
@@ -569,6 +570,7 @@ static void verify_tree(BVHTree *tree)
        
        printf("branches: %d, leafs: %d, total: %d\n", tree->totbranch, tree->totleaf, tree->totbranch + tree->totleaf);
 }
+#endif
        
 void BLI_bvhtree_balance(BVHTree *tree)
 {
index 7bbf0c4732edfee06f3736efd7c61d9f17cc4318..7ac7b8b17918dde0f907a104bb2c6f640771b204 100644 (file)
@@ -89,7 +89,6 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk)
        curnode->next = NULL;
        return pool;
 }
-
 void *BLI_mempool_alloc(BLI_mempool *pool){
        void *retval=NULL;
        BLI_freenode *curnode=NULL;
@@ -117,6 +116,16 @@ void *BLI_mempool_alloc(BLI_mempool *pool){
        //memset(retval, 0, pool->esize);
        return retval;
 }
+
+void *BLI_mempool_calloc(BLI_mempool *pool){
+       void *retval=NULL;
+       retval = BLI_mempool_alloc(pool);
+       memset(retval, 0, pool->esize);
+       return retval;
+}
+
+
+
 void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against double frees, dont be stupid!
        BLI_freenode *newhead = addr;
        newhead->next = pool->free;
@@ -128,4 +137,4 @@ void BLI_mempool_destroy(BLI_mempool *pool)
        for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) MEM_freeN(mpchunk->data);
        BLI_freelistN(&(pool->chunks));
        MEM_freeN(pool);
-}
\ No newline at end of file
+}
index ca7a376d3a2bc96235d1f48e05e183022cbe68ff..fbcc56ac21d69cd289de6d3e26080cd1d2a2b0d9 100644 (file)
@@ -382,6 +382,7 @@ void BLI_adddirstrings()
                        pwuser = getpwuid(files[num].s.st_uid);
                        if ( pwuser ) {
                        strcpy(files[num].owner, pwuser->pw_name);
+                       free(pwuser);
                        } else {
                                sprintf(files[num].owner, "%d", files[num].s.st_uid);
             }
index 5a85fbfc37500341c4295ec72ecf6dfc414bedcf..48ebf770e1bcd428917af994032608de33039321 100644 (file)
@@ -1722,6 +1722,7 @@ void BLI_where_am_i(char *fullname, const char *name)
        path = br_find_exe( NULL );
        if (path) {
                strcpy(fullname, path);
+               free(path);
                return;
        }
 #endif
index b59908fef39715c2c2fea2e78e823bf3eab76649..fe352610a40cb36fcdd2c4c4103bb3452826a5c2 100644 (file)
@@ -842,7 +842,7 @@ typedef struct RGBA
 } RGBA;
 
 
-#if 0
+/* debug only */
 static void exr_print_filecontents(InputFile *file)
 {
        const ChannelList &channels = file->header().channels();
@@ -853,7 +853,27 @@ static void exr_print_filecontents(InputFile *file)
                printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type);
        }
 }
-#endif
+
+/* for non-multilayer, map  R G B A channel names to something that's in this file */
+static const char *exr_rgba_channelname(InputFile *file, const char *chan)
+{
+       const ChannelList &channels = file->header().channels();
+       
+       for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
+       {
+               const Channel &channel = i.channel();
+               const char *str= i.name();
+               int len= strlen(str);
+               if(len) {
+                       if(BLI_strcasecmp(chan, str+len-1)==0) {
+                               return str;
+                       }
+               }
+       }
+       return chan;
+}
+
+
 
 static int exr_has_zbuffer(InputFile *file)
 {
@@ -896,7 +916,8 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
                //printf("OpenEXR-load: image data window %d %d %d %d\n", 
                //         dw.min.x, dw.min.y, dw.max.x, dw.max.y);
 
-               // exr_print_filecontents(file);
+               if(0) // debug
+                       exr_print_filecontents(file);
                
                is_multi= exr_is_renderresult(file);
                
@@ -935,11 +956,15 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
                                        /* but, since we read y-flipped (negative y stride) we move to last scanline */
                                        first+= 4*(height-1)*width;
                                        
-                                       frameBuffer.insert ("R", Slice (FLOAT,  (char *) first, xstride, ystride));
-                                       frameBuffer.insert ("G", Slice (FLOAT,  (char *) (first+1), xstride, ystride));
-                                       frameBuffer.insert ("B", Slice (FLOAT,  (char *) (first+2), xstride, ystride));
-                                                                                                                                                       /* 1.0 is fill value */
-                                       frameBuffer.insert ("A", Slice (FLOAT,  (char *) (first+3), xstride, ystride, 1, 1, 1.0f));
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "R"), 
+                                                                               Slice (FLOAT,  (char *) first, xstride, ystride));
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "G"), 
+                                                                               Slice (FLOAT,  (char *) (first+1), xstride, ystride));
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "B"), 
+                                                                               Slice (FLOAT,  (char *) (first+2), xstride, ystride));
+                                                                                                                                                       
+                                       frameBuffer.insert ( exr_rgba_channelname(file, "A"), 
+                                                                               Slice (FLOAT,  (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */
 
                                        if(exr_has_zbuffer(file)) 
                                        {
index 3f9a6e438ccadb4801c762170450ffd3cf2abef8..de28db64c3b11a6fdca418da0a5ba32004e5f740 100644 (file)
@@ -63,6 +63,7 @@ void get_local_bounds(struct Object *ob, float *center, float *size);
 /* drawing flags: */
 #define DRAW_PICKING   1
 #define DRAW_CONSTCOLOR        2
+#define DRAW_SCENESET  4
 void draw_object(struct Base *base, int flag);
 void drawaxes(float size, int flag, char drawtype);
 
index 0e1557ac3780df9f153decd81d1574a39c6add93..24112c7f11afd2664d69804428f2748f19aaa5e5 100644 (file)
@@ -80,7 +80,7 @@ void  clear_armature(struct Object *ob, char mode);
 void   delete_armature(void);
 void   deselectall_armature(int toggle, int doundo);
 void   deselectall_posearmature (struct Object *ob, int test, int doundo);
-int            draw_armature(struct Base *base, int dt);
+int            draw_armature(struct Base *base, int dt, int flag);
 
 void   extrude_armature(int forked);
 void   subdivide_armature(int numcuts);
index 15a9218b73573778b7878663308a3adfbfd9b884..0d96de7be6035db7f3aa2f25e0830a56b9cc100a 100644 (file)
@@ -92,6 +92,8 @@ void update_changed_seq_and_deps(struct Sequence *seq, int len_change, int ibuf_
 struct RenderResult;
 void do_render_seq(struct RenderResult *rr, int cfra);
 
+int seq_can_blend(struct Sequence *seq);
+
 #define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE)
 
 #endif
index 3cf80a4efa616605308b2f631f4800a8a55db4b3..a467722e8e19d3b3048819fa1a408d82ac17d470 100644 (file)
@@ -51,8 +51,9 @@ typedef struct bActionActuator {
        int     sta, end;               /* Start & End frames */                        
        char    name[32];               /* For property-driven playback */      
        char    frameProp[32];  /* Set this property to the actions current frame */
-       int     blendin;                /* Number of frames of blending */      
-       short   priority;               /* Execution priority */                        
+       short   blendin;                /* Number of frames of blending */
+       short   priority;               /* Execution priority */
+       short   end_reset;      /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
        short   strideaxis;             /* Displacement axis */
        float   stridelength;   /* Displacement incurred by cycle */
 } bActionActuator;                                                                                             
@@ -339,8 +340,9 @@ typedef struct FreeCamera {
 /* ipoactuator->flag */
 #define ACT_IPOFORCE        (1 << 0)
 #define ACT_IPOEND          (1 << 1)
-#define ACT_IPOFORCE_LOCAL  (1 << 2)
-#define ACT_IPOCHILD        (1 << 4)                   
+#define ACT_IPOLOCAL           (1 << 2)
+#define ACT_IPOCHILD        (1 << 4)   
+#define ACT_IPOADD                     (1 << 5)
 
 /* ipoactuator->flag for k2k */
 #define ACT_K2K_PREV           1
index af60f9ca71363a99686fc4f58eff2cd37b3ce8d7..bc30a12ff274da92425398eeb4a5f83a4bce105f 100644 (file)
@@ -232,8 +232,9 @@ typedef struct SpaceImage {
        short imanr;
        short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
        int flag;
+       short selectmode;
        short imtypenr, lock;
-       short pin, pad2;
+       short pin;
        float zoom;
        char dt_uv; /* UV draw type */
        char sticky; /* sticky selection type */
@@ -496,6 +497,12 @@ typedef struct SpaceImaSel {
 #define SI_STICKY_DISABLE      1
 #define SI_STICKY_VERTEX       2
 
+/* SpaceImage->selectmode */
+#define SI_SELECT_VERTEX       0
+#define SI_SELECT_EDGE         1 /* not implemented */
+#define SI_SELECT_FACE         2
+#define SI_SELECT_ISLAND       3
+
 /* SpaceImage->flag */
 #define SI_BE_SQUARE   1<<0
 #define SI_EDITTILE            1<<1
@@ -503,7 +510,7 @@ typedef struct SpaceImaSel {
 #define SI_DRAWTOOL            1<<3
 #define SI_DEPRECATED1  1<<4   /* stick UVs to others in the same location */
 #define SI_DRAWSHADOW   1<<5
-#define SI_SELACTFACE   1<<6
+#define SI_SELACTFACE   1<<6   /* deprecated */
 #define SI_DEPRECATED2 1<<7
 #define SI_DEPRECATED3  1<<8   /* stick UV selection to mesh vertex (UVs wont always be touching) */
 #define SI_COORDFLOATS  1<<9
index ff9e2b716ce902be6ad317c7a02e9326ab16522e..e77de3726cba63a8631ba7375e798d46d39ba381 100644 (file)
@@ -47,7 +47,7 @@ static void do_gamma(bNode *node, float *out, float *in, float *fac)
        int i=0;
        for(i=0; i<3; i++) {
                /* check for negative to avoid nan's */
-               out[i] = (in[0] > 0.0f)? pow(in[i],fac[0]): in[0];
+               out[i] = (in[i] > 0.0f)? pow(in[i],fac[0]): in[i];
        }
        out[3] = in[3];
 }
index 56821980cd2dc7d1071cc68faa61f1e9812e2664..0d3ad3fcb4458ec2ba7068c59cb80733f38c157d 100644 (file)
@@ -81,6 +81,7 @@ returns None if notfound.\nIf 'name' is not specified, it returns a list of all
 static PyObject *Sequence_copy( BPy_Sequence * self );
 static PyObject *Sequence_new( BPy_Sequence * self, PyObject * args );
 static PyObject *Sequence_remove( BPy_Sequence * self, PyObject * args );
+static PyObject *Sequence_rebuildProxy( BPy_Sequence * self );
 
 static PyObject *SceneSeq_new( BPy_SceneSeq * self, PyObject * args );
 static PyObject *SceneSeq_remove( BPy_SceneSeq * self, PyObject * args );
@@ -96,6 +97,8 @@ static PyMethodDef BPy_Sequence_methods[] = {
         "() - Return a copy of the sequence containing the same objects."},
        {"copy", ( PyCFunction ) Sequence_copy, METH_NOARGS,
         "() - Return a copy of the sequence containing the same objects."},
+       {"rebuildProxy", ( PyCFunction ) Sequence_rebuildProxy, METH_VARARGS,
+        "() - Rebuild the active strip's Proxy."},
        {NULL, NULL, 0, NULL}
 };
 
@@ -309,6 +312,7 @@ static PyObject *Sequence_copy( BPy_Sequence * self )
        Py_RETURN_NONE;
 }
 
+
 /*****************************************************************************/
 /* PythonTypeObject callback function prototypes                        */
 /*****************************************************************************/
@@ -383,8 +387,6 @@ static PyObject *SceneSeq_nextIter( BPy_Sequence * self )
 }
 
 
-
-
 static PyObject *Sequence_getName( BPy_Sequence * self )
 {
        return PyString_FromString( self->seq->name+2 );
@@ -403,11 +405,13 @@ static int Sequence_setName( BPy_Sequence * self, PyObject * value )
        return 0;
 }
 
+
 static PyObject *Sequence_getProxyDir( BPy_Sequence * self )
 {
        return PyString_FromString( self->seq->strip->proxy ? self->seq->strip->proxy->dir : "" );
 }
 
+
 static int Sequence_setProxyDir( BPy_Sequence * self, PyObject * value )
 {
        char *name = NULL;
@@ -430,6 +434,14 @@ static int Sequence_setProxyDir( BPy_Sequence * self, PyObject * value )
 }
 
 
+static PyObject *Sequence_rebuildProxy( BPy_Sequence * self )
+{
+       if (self->seq->strip->proxy)
+               seq_proxy_rebuild(self->seq);
+       Py_RETURN_NONE;
+}
+
+
 static PyObject *Sequence_getSound( BPy_Sequence * self )
 {
        if (self->seq->type == SEQ_RAM_SOUND && self->seq->sound)
@@ -622,6 +634,54 @@ static int Sequence_setImages( BPy_Sequence * self, PyObject *value )
        return 0;
 }
 
+static PyObject *M_Sequence_BlendModesDict( void )
+{
+       PyObject *M = PyConstant_New(  );
+
+       if( M ) {
+               BPy_constant *d = ( BPy_constant * ) M;
+               PyConstant_Insert( d, "CROSS", PyInt_FromLong( SEQ_CROSS ) );
+               PyConstant_Insert( d, "ADD", PyInt_FromLong( SEQ_ADD ) );
+               PyConstant_Insert( d, "SUBTRACT", PyInt_FromLong( SEQ_SUB ) );
+               PyConstant_Insert( d, "ALPHAOVER", PyInt_FromLong( SEQ_ALPHAOVER ) );
+               PyConstant_Insert( d, "ALPHAUNDER", PyInt_FromLong( SEQ_ALPHAUNDER ) );
+               PyConstant_Insert( d, "GAMMACROSS", PyInt_FromLong( SEQ_GAMCROSS ) );
+               PyConstant_Insert( d, "MULTIPLY", PyInt_FromLong( SEQ_MUL ) );
+               PyConstant_Insert( d, "OVERDROP", PyInt_FromLong( SEQ_OVERDROP ) );
+               PyConstant_Insert( d, "PLUGIN", PyInt_FromLong( SEQ_PLUGIN ) );
+               PyConstant_Insert( d, "WIPE", PyInt_FromLong( SEQ_WIPE ) );
+               PyConstant_Insert( d, "GLOW", PyInt_FromLong( SEQ_GLOW ) );
+               PyConstant_Insert( d, "TRANSFORM", PyInt_FromLong( SEQ_TRANSFORM ) );
+               PyConstant_Insert( d, "COLOR", PyInt_FromLong( SEQ_COLOR ) );
+               PyConstant_Insert( d, "SPEED", PyInt_FromLong( SEQ_SPEED ) );
+       }
+       return M;
+}
+
+static PyObject *Sequence_getBlendMode( BPy_Sequence * self )
+{
+       return PyInt_FromLong( self->seq->blend_mode );
+}
+
+static int Sequence_setBlendMode( BPy_Sequence * self, PyObject * value )
+{
+       struct Sequence *seq= self->seq;
+       int number = PyInt_AsLong( value );
+       
+       if( number==-1 && PyErr_Occurred() )
+               return EXPP_ReturnIntError( PyExc_TypeError, "expected an int value" );
+       
+       if ( !seq_can_blend(seq) )
+               return EXPP_ReturnIntError( PyExc_AttributeError, "this sequence type dosnt support blending" );        
+       
+       if (number<SEQ_EFFECT || number>SEQ_EFFECT_MAX)
+               return EXPP_ReturnIntError( PyExc_TypeError, "expected an int value" );
+       
+       seq->blend_mode=number;
+       
+       return 0;
+}
+
 /*
  * get floating point attributes
  */
@@ -836,7 +896,11 @@ static PyGetSetDef BPy_Sequence_getseters[] = {
         (getter)Sequence_getImages, (setter)Sequence_setImages,
         "Sequence scene",
          NULL},
-         
+       {"blendMode",
+        (getter)Sequence_getBlendMode, (setter)Sequence_setBlendMode,
+        "Sequence Blend Mode",
+         NULL},
+
        {"type",
         (getter)getIntAttr, (setter)NULL,
         "",
@@ -1131,6 +1195,7 @@ PyObject *M_Sequence_Get( PyObject * self, PyObject * args )
 /*****************************************************************************/
 PyObject *Sequence_Init( void )
 {
+       PyObject *BlendModesDict = M_Sequence_BlendModesDict( );
        PyObject *submodule;
        if( PyType_Ready( &Sequence_Type ) < 0 )
                return NULL;
@@ -1142,6 +1207,9 @@ PyObject *Sequence_Init( void )
 "The Blender Sequence module\n\n\
 This module provides access to **Sequence Data** in Blender.\n" );
 
+       if( BlendModesDict )
+               PyModule_AddObject( submodule, "BlendModes", BlendModesDict );
+
        /*Add SUBMODULES to the module*/
        /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); //creates a *new* module*/
        return submodule;
index e5ef1e9a4a2e869dea53e54832c5374852aaeb95..68b5fa81f43c4347065a23a52770b92c8ebeb464 100644 (file)
@@ -369,9 +369,18 @@ printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
                        if(vlr->mat->mode & MA_RADIO) {
                                
                                /* during render, vlr->n gets flipped/corrected, we cannot have that */
-                               if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
-                               else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
-                               
+                               if (obr->ob->transflag & OB_NEG_SCALE){
+                                       /* The object has negative scale that will cause the normals to flip.
+                                                To counter this unwanted normal flip, swap vertex 2 and 4 for a quad
+                                                or vertex 2 and 3 (see flip_face) for a triangle in the call to CalcNormFloat4 
+                                                in order to flip the normals back to the way they were in the original mesh. */
+                                       if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v4->co, vlr->v3->co, vlr->v2->co, rf->norm);
+                                       else CalcNormFloat(vlr->v1->co, vlr->v3->co, vlr->v2->co, rf->norm);
+                               }else{
+                                       if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
+                                       else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
+                               }
+
                                rf->totrad[0]= vlr->mat->emit*vlr->mat->r;
                                rf->totrad[1]= vlr->mat->emit*vlr->mat->g;
                                rf->totrad[2]= vlr->mat->emit*vlr->mat->b;
index f9ec0e9d8437c0ea861b1d09052393d0116218d0..faa7a68f75421390db0f51d6bfdcd8bf35c82e34 100644 (file)
@@ -204,6 +204,7 @@ void RE_make_stars(Render *re, void (*initfunc)(void),
        else stargrid *= 1.0;                           /* then it draws fewer */
        
        if(re) MTC_Mat4Invert(mat, re->viewmat);
+       else MTC_Mat4One(mat);
        
        /* BOUNDING BOX CALCULATION
                * bbox goes from z = loc_near_var | loc_far_var,
index 1a9e10306888b22ad6041cdd168acb5e033a368d..cc4df06e22d49f306bfacbd6409c01525dcaf6b9 100644 (file)
@@ -1560,7 +1560,6 @@ static void set_col_actuator(int item, int medium)
 static void change_object_actuator(void *act, void *arg)
 {
        bObjectActuator *oa = act;
-       int i;
 
        if (oa->type != oa->otype) {
                switch (oa->type) {
@@ -1582,6 +1581,18 @@ static void change_object_actuator(void *act, void *arg)
        }
 }
 
+static void change_ipo_actuator(void *arg1_but, void *arg2_ia)
+{
+       bIpoActuator *ia = arg2_ia;
+       uiBut *but = arg1_but;
+
+       if (but->retval & ACT_IPOFORCE)
+               ia->flag &= ~ACT_IPOADD;
+       else if (but->retval & ACT_IPOADD)
+               ia->flag &= ~ACT_IPOFORCE;
+       but->retval = B_REDR;
+}
+
 void update_object_actuator_PID(void *act, void *arg)
 {
        bObjectActuator *oa = act;
@@ -1679,7 +1690,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
                                uiDefButF(block, NUM, 0, "",            xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, "");
                                
                                uiDefBut(block, LABEL, 0, "damp",       xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity");
-                               uiDefButI(block, NUM, 0, "",            xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, "");
+                               uiDefButS(block, NUM, 0, "",            xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, "");
 
                                uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L",               xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
                                uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L",              xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
@@ -1758,23 +1769,27 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
 #else
                        str= "Action types   %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
 #endif
-                       uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, (width-60)/2, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type");
-                       uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+30 + ((width-60)/2), yco-24, (width-60)/2, 19, &aa->act, "Action name");
+                       uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, width/3, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type");
+                       uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+10+ (width/3), yco-24, ((width/3)*2) - (20 + 60), 19, &aa->act, "Action name");
+                       
+                       uiDefButBitS(block, TOGN, 1, 0, "Continue", xco+((width/3)*2)+20, yco-24, 60, 19,
+                                        &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time");
+                       
                        
                        if(aa->type == ACT_ACTION_FROM_PROP)
                        {
-                               uiDefBut(block, TEX, 0, "Prop: ",xco+30, yco-44, width-60, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position");
+                               uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position");
                        }
                        else
                        {
-                               uiDefButI(block, NUM, 0, "Sta: ",xco+30, yco-44, (width-60)/2, 19, &aa->sta, 0.0, MAXFRAMEF, 0, 0, "Start frame");
-                               uiDefButI(block, NUM, 0, "End: ",xco+30+(width-60)/2, yco-44, (width-60)/2, 19, &aa->end, 0.0, MAXFRAMEF, 0, 0, "End frame");
+                               uiDefButI(block, NUM, 0, "Sta: ",xco+10, yco-44, (width-20)/2, 19, &aa->sta, 0.0, MAXFRAMEF, 0, 0, "Start frame");
+                               uiDefButI(block, NUM, 0, "End: ",xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &aa->end, 0.0, MAXFRAMEF, 0, 0, "End frame");
                        }
                                                
-                       uiDefButI(block, NUM, 0, "Blendin: ", xco+30, yco-64, (width-60)/2, 19, &aa->blendin, 0.0, MAXFRAMEF, 0.0, 0.0, "Number of frames of motion blending");
-                       uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack");
+                       uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending");
+                       uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack");
                        
-                       uiDefBut(block, TEX, 0, "FrameProp: ",xco+30, yco-84, width-60, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number");                  
+                       uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number");                  
 
                        
 #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
@@ -1800,42 +1815,49 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
                        
                        str = "Ipo types   %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
                        
-                       uiDefButS(block, MENU, B_REDR, str,             xco+20, yco-24, width-40 - (width-40)/3, 19, &ia->type, 0, 0, 0, 0, "");
-                       uiDefButBitS(block, TOG, ACT_IPOCHILD,  B_REDR, 
-                               "Child",        xco+20+0.666*(width-40), yco-24, (width-40)/3, 19, 
+                       uiDefButS(block, MENU, B_REDR, str,             xco+10, yco-24, (width-20)/2, 19, &ia->type, 0, 0, 0, 0, "");
+
+                       but = uiDefButBitS(block, TOG, ACT_IPOFORCE, ACT_IPOFORCE, 
+                               "Force", xco+10+(width-20)/2, yco-24, (width-20)/4-10, 19, 
                                &ia->flag, 0, 0, 0, 0, 
-                               "Add all children Objects as well");
+                               "Convert Ipo to force. Force is applied in global or local coordinate according to Local flag"); 
+                       uiButSetFunc(but, change_ipo_actuator, but, ia);
+
+                       but = uiDefButBitS(block, TOG, ACT_IPOADD, ACT_IPOADD, 
+                               "Add", xco+3*(width-20)/4, yco-24, (width-20)/4-10, 19, 
+                               &ia->flag, 0, 0, 0, 0, 
+                               "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); 
+                       uiButSetFunc(but, change_ipo_actuator, but, ia);
+                       
+                       /* Only show the do-force-local toggle if force is requested */
+                       if (ia->flag & (ACT_IPOFORCE|ACT_IPOADD)) {
+                               uiDefButBitS(block, TOG, ACT_IPOLOCAL, 0, 
+                                       "L", xco+width-30, yco-24, 20, 19, 
+                                       &ia->flag, 0, 0, 0, 0, 
+                                       "Let the ipo acts in local coordinates, used in Force and Add mode."); 
+                       }
 
                        if(ia->type==ACT_IPO_FROM_PROP) {
                                uiDefBut(block, TEX, 0, 
-                                       "Prop: ",               xco+20, yco-44, width-40, 19, 
+                                       "Prop: ",               xco+10, yco-44, width-80, 19, 
                                        ia->name, 0.0, 31.0, 0, 0, 
                                        "Use this property to define the Ipo position");
                        }
                        else {
                                uiDefButI(block, NUM, 0, 
-                                       "Sta",          xco+20, yco-44, (width-100)/2, 19, 
+                                       "Sta",          xco+10, yco-44, (width-80)/2, 19, 
                                        &ia->sta, 0.0, MAXFRAMEF, 0, 0, 
-                                       "Start frame");
+                                       "Start frame, (subtract 1 to match blenders frame numbers)");
                                uiDefButI(block, NUM, 0, 
-                                       "End",          xco+18+(width-90)/2, yco-44, (width-100)/2, 19, 
+                                       "End",          xco+10+(width-80)/2, yco-44, (width-80)/2, 19, 
                                        &ia->end, 0.0, MAXFRAMEF, 0, 0, 
-                                       "End frame");
-                               
-                               uiDefButBitS(block, TOG, ACT_IPOFORCE, B_REDR, 
-                                       "Force", xco+width-78, yco-44, 43, 19, 
-                                       &ia->flag, 0, 0, 0, 0, 
-                                       "Convert Ipo to force"); 
-                               
-                               /* Only show the do-force-local toggle if force is requested */
-                               if (ia->flag & ACT_IPOFORCE) {
-                                       uiDefButBitS(block, TOG, ACT_IPOFORCE_LOCAL, 0, 
-                                               "L", xco+width-35, yco-44, 15, 19, 
-                                               &ia->flag, 0, 0, 0, 0, 
-                                               "Let the force-ipo act in local coordinates."); 
-                               }
-                               
+                                       "End frame, (subtract 1 to match blenders frame numbers)");
                        }
+                       uiDefButBitS(block, TOG, ACT_IPOCHILD,  B_REDR, 
+                               "Child",        xco+10+(width-80), yco-44, 60, 19, 
+                               &ia->flag, 0, 0, 0, 0, 
+                               "Update IPO on all children Objects as well");
+
                        yco-= ysize;
                        break;
                }
@@ -1967,7 +1989,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
                        glRects(xco, yco-ysize, xco+width, yco);
                        uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
         
-                       uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",         xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object (cant be on an visible layer)");
+                       uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",         xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)");
                        uiDefButI(block, NUM, 0, "Time:",       xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives");
 
                        wval= (width-60)/3;
@@ -2248,7 +2270,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
                        uiDefBut(block, TEX, 0, "Prop: ",               xco+20, yco-44, width-40, 19, ga->name, 0.0, 31.0, 0, 0, "Use this property to define the Group position");
                }
                else {
-                       uiDefButI(block, NUM, 0, "Sta",         xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame");
+                       uiDefButI(block, NUM, 0, "State",               xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame");
                        uiDefButI(block, NUM, 0, "End",         xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame");
                }
                yco-= ysize;
@@ -3171,7 +3193,7 @@ void logic_buts(void)
                                        uiButSetFunc(but, check_object_state, but, &(ob->state));
                                }
                                for (stbit=0; stbit<5; stbit++) {
-                                       but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "",       (short)(xco+35+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
+                                       but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "",    (short)(xco+35+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
                                        uiButSetFunc(but, check_object_state, but, &(ob->state));
                                }
                        }
@@ -3255,7 +3277,7 @@ void logic_buts(void)
        uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+80, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
        uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+80+(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
        uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+80+2*(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
-       uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "Sta", xco+80+3*(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states");
+       uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "State", xco+80+3*(width-70)/4, yco+35, (width-70)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states");
        uiBlockEndAlign(block);
        
        for(a=0; a<count; a++) {
@@ -3328,7 +3350,7 @@ void logic_buts(void)
        uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show all selected Objects");
        uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show active Object");
        uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
-       uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "Sta", xco+110+3*(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states");
+       uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "State", xco+110+3*(width-100)/4, yco+35, (width-100)/4, 19, &G.buts->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states");
        uiBlockEndAlign(block);
        for(a=0; a<count; a++) {
                ob= (Object *)idar[a];
index ba409723784c5b44673d3aa3d2ad7f22337eb8ee..ebe770c89e77de2cc8c1546d8c00a7d2e61becdd 100644 (file)
@@ -4812,7 +4812,7 @@ static void object_panel_particle_system(Object *ob)
        uiDefBut(block, LABEL, 0, "Basic:",                                     butx,(buty-=buth),butw,buth, NULL, 0.0, 0, 0, 0, "");
        uiBlockBeginAlign(block);
 
-       if(part->distr==PART_DISTR_GRID)
+       if(part->distr==PART_DISTR_GRID && part->from != PART_FROM_VERT)
                uiDefButI(block, NUM, B_PART_ALLOC, "Resol:",           butx,(buty-=buth),butw,buth, &part->grid_res, 1.0, 100.0, 0, 0, "The resolution of the particle grid");
        else
                uiDefButI(block, NUM, B_PART_ALLOC, "Amount:",          butx,(buty-=buth),butw,buth, &part->totpart, 0.0, 100000.0, 0, 0, "The total number of particles");
index f136599519cdf4eb15d09feb5844c6322f25d5c3..a58d44538a27a78816910566a5faeefba5e35a23 100644 (file)
@@ -499,7 +499,7 @@ static char* seq_panel_blend_modes()
          so that would collide also.
        */
 
-       if (!(last_seq->type & SEQ_EFFECT)) {
+       if ( seq_can_blend(last_seq) ) {
                int i;
 
                for (i = SEQ_EFFECT; i <= SEQ_EFFECT_MAX; i++) {
index ca6705b208457060d48ee192925b6105947d3e08..1b580381ca5d9c715870e5596774c92369e93f57 100644 (file)
@@ -2900,15 +2900,15 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
                uiBlockSetCol(block, TH_BUT_SETTING1);
                uiDefButS(block, MENU, B_LAMPREDRAW,  "Falloff %t|Constant %x0|Inverse Linear %x1|Inverse Square %x2|Custom Curve %x3|Lin/Quad Weighted %x4|",
                        10,150,100,19, &la->falloff_type, 0,0,0,0, "Lamp falloff - intensity decay with distance");     
-               uiDefButBitS(block, TOG, LA_SPHERE, REDRAWVIEW3D,"Sphere",      10,130,100,19,&la->mode, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
+               uiDefButBitS(block, TOG, LA_SPHERE, B_LAMPPRV,"Sphere", 10,130,100,19,&la->mode, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
        }
 
        uiBlockBeginAlign(block);
        uiBlockSetCol(block, TH_BUT_SETTING1);
        uiDefButBitS(block, TOG, LA_LAYER, 0,"Layer",                           10,70,100,19,&la->mode, 0, 0, 0, 0, "Illuminates objects in the same layer as the lamp only");
        uiDefButBitS(block, TOG, LA_NEG, B_LAMPPRV,"Negative",  10,50,100,19,&la->mode, 0, 0, 0, 0, "Sets lamp to cast negative light");
-       uiDefButBitS(block, TOG, LA_NO_DIFF, 0,"No Diffuse",            10,30,100,19,&la->mode, 0, 0, 0, 0, "Disables diffuse shading of material illuminated by this lamp");
-       uiDefButBitS(block, TOG, LA_NO_SPEC, 0,"No Specular",           10,10,100,19,&la->mode, 0, 0, 0, 0, "Disables specular shading of material illuminated by this lamp");
+       uiDefButBitS(block, TOG, LA_NO_DIFF, B_LAMPPRV,"No Diffuse",            10,30,100,19,&la->mode, 0, 0, 0, 0, "Disables diffuse shading of material illuminated by this lamp");
+       uiDefButBitS(block, TOG, LA_NO_SPEC, B_LAMPPRV,"No Specular",           10,10,100,19,&la->mode, 0, 0, 0, 0, "Disables specular shading of material illuminated by this lamp");
        uiBlockEndAlign(block);
 
        uiBlockSetCol(block, TH_AUTO);
index 73915a69139cb3b4a569c4bc5d141559ff2668d7..6d78b21dfbbb6fd4107ad52fd8bfeb38511c91b3 100644 (file)
@@ -2500,7 +2500,7 @@ static void draw_ghost_poses(Base *base)
 /* ********************************** Armature Drawing - Main ************************* */
 
 /* called from drawobject.c, return 1 if nothing was drawn */
-int draw_armature(Base *base, int dt)
+int draw_armature(Base *base, int dt, int flag)
 {
        Object *ob= base->object;
        bArmature *arm= ob->data;
@@ -2544,15 +2544,16 @@ int draw_armature(Base *base, int dt)
                                                if (arm->ghostep)
                                                        draw_ghost_poses(base);
                                        }
+                                       if ((flag & DRAW_SCENESET)==0) {
+                                               if(ob==OBACT) 
+                                                       arm->flag |= ARM_POSEMODE;
+                                               else if(G.f & G_WEIGHTPAINT)
+                                                       arm->flag |= ARM_POSEMODE;
                                        
-                                       if(ob==OBACT) 
-                                               arm->flag |= ARM_POSEMODE;
-                                       else if(G.f & G_WEIGHTPAINT)
-                                               arm->flag |= ARM_POSEMODE;
-                                       
-                                       draw_pose_paths(ob);
+                                               draw_pose_paths(ob);
+                                       }
                                }       
-                       }                       
+                       }
                        draw_pose_channels(base, dt);
                        arm->flag &= ~ARM_POSEMODE; 
                        
index 547de85e8562833dc1faf4c520605b8369dcd23d..14849cdd4505b7ca3d24c2a234348c818a7f6409 100644 (file)
@@ -422,7 +422,7 @@ int draw_uvs_face_check(void)
                        return 1;
                } 
        } else {
-               if (G.sima->flag & SI_SELACTFACE) {
+               if (G.sima->selectmode == SI_SELECT_FACE) {
                        return 1;
                }
        }
index 96ba8c717556990ad689259941bbde07108e92f5..045bf292446225718cd1e6bad03250c3d716d32c 100644 (file)
@@ -4620,7 +4620,7 @@ static void drawSolidSelect(Base *base)
        }
        else if(ob->type==OB_ARMATURE) {
                if(!(ob->flag & OB_POSEMODE)) {
-                       draw_armature(base, OB_WIRE);
+                       draw_armature(base, OB_WIRE, 0);
                }
        }
 
@@ -4741,7 +4741,7 @@ void drawRBpivot(bRigidBodyJointConstraint *data){
        setlinestyle(0);
 }
 
-/* flag can be DRAW_PICKING    and/or DRAW_CONSTCOLOR */
+/* flag can be DRAW_PICKING    and/or DRAW_CONSTCOLOR, DRAW_SCENESET */
 void draw_object(Base *base, int flag)
 {
        static int warning_recursive= 0;
@@ -4943,7 +4943,7 @@ void draw_object(Base *base, int flag)
 
        /* draw outline for selected solid objects, mesh does itself */
        if((G.vd->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) {
-               if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=G.obedit) {
+               if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=G.obedit && (flag && DRAW_SCENESET)==0) {
                        if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) {
                                drawSolidSelect(base);
                        }
@@ -5090,7 +5090,7 @@ void draw_object(Base *base, int flag)
                        break;
                case OB_ARMATURE:
                        if(dt>OB_WIRE) set_gl_material(0);      // we use defmaterial
-                       empty_object= draw_armature(base, dt);
+                       empty_object= draw_armature(base, dt, flag);
                        break;
                default:
                        drawaxes(1.0, flag, OB_ARROWS);
index 2f1cdb8b951b4a28f9bba3c1f6504a8dca40706a..f595a101f63e3484a069430faa44f09bf2de62f8 100644 (file)
@@ -3097,7 +3097,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
                        if(v3d->lay & base->lay) {
                                
                                BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
-                               draw_object(base, DRAW_CONSTCOLOR);
+                               draw_object(base, DRAW_CONSTCOLOR|DRAW_SCENESET);
 
                                if(base->object->transflag & OB_DUPLI) {
                                        draw_dupli_objects_color(v3d, base, TH_WIRE);
@@ -3319,7 +3319,7 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]
                                        where_is_object(base->object);
        
                                        BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
-                                       draw_object(base, DRAW_CONSTCOLOR);
+                                       draw_object(base, DRAW_CONSTCOLOR|DRAW_SCENESET);
        
                                        if(base->object->transflag & OB_DUPLI) {
                                                draw_dupli_objects(v3d, base);
index 39f93510358318ff5565e9357e6b06e197453ace..6310dd0a262c8e6a85bd0139af08c004d19b36f3 100644 (file)
@@ -1646,8 +1646,9 @@ void load_editArmature(void)
 }
 
 /* toggle==0: deselect
-   toggle==1: swap 
+   toggle==1: swap (based on test)
    toggle==2: only active tag
+   toggle==3: swap (no test)
 */
 void deselectall_armature(int toggle, int doundo)
 {
@@ -1670,18 +1671,30 @@ void deselectall_armature(int toggle, int doundo)
        else sel= toggle;
        
        /*      Set the flags */
-       for (eBone=G.edbo.first;eBone;eBone=eBone->next){
-               if (sel==1) {
+       for (eBone=G.edbo.first;eBone;eBone=eBone->next) {
+               if (sel==3) {
+                       /* invert selection of bone */
+                       if ((arm->layer & eBone->layer) && (eBone->flag & BONE_HIDDEN_A)==0) {
+                               eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+                               eBone->flag &= ~BONE_ACTIVE;
+                       }
+               }
+               else if (sel==1) {
+                       /* select bone */
                        if(arm->layer & eBone->layer && (eBone->flag & BONE_HIDDEN_A)==0) {
                                eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                                if(eBone->parent)
                                        eBone->parent->flag |= (BONE_TIPSEL);
                        }
                }
-               else if (sel==2)
+               else if (sel==2) {
+                       /* clear active flag */
                        eBone->flag &= ~(BONE_ACTIVE);
-               else
+               }
+               else {
+                       /* deselect bone */
                        eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE);
+               }
        }
        
        allqueue(REDRAWVIEW3D, 0);
@@ -3276,8 +3289,9 @@ int do_pose_selectbuffer(Base *base, unsigned int *buffer, short hits)
 }
 
 /* test==0: deselect all
-   test==1: swap select
-   test==2: only clear active tag 
+   test==1: swap select (apply to all the opposite of current situation) 
+   test==2: only clear active tag
+   test==3: swap select (no test / inverse selection status of all independently)
 */
 void deselectall_posearmature (Object *ob, int test, int doundo)
 {
@@ -3307,16 +3321,27 @@ void deselectall_posearmature (Object *ob, int test, int doundo)
        /*      Set the flags accordingly       */
        for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
                if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
-                       if (selectmode==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE);
-                       else if (selectmode==1) pchan->bone->flag |= BONE_SELECTED;
-                       else pchan->bone->flag &= ~BONE_ACTIVE;
+                       if (test==3) {
+                               pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+                               pchan->bone->flag &= ~BONE_ACTIVE;
+                       }
+                       else {
+                               if (selectmode==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE);
+                               else if (selectmode==1) pchan->bone->flag |= BONE_SELECTED;
+                               else pchan->bone->flag &= ~BONE_ACTIVE;
+                       }
                }
        }
        
        /* action editor */
-       deselect_actionchannels(ob->action, 0); /* deselects for sure */
-       if (selectmode == 1)
-               deselect_actionchannels(ob->action, 1); /* swaps */
+       if (test == 3) {
+               deselect_actionchannels(ob->action, 2); /* inverts selection */
+       }
+       else {
+               deselect_actionchannels(ob->action, 0); /* deselects for sure */
+               if (selectmode == 1)
+                       deselect_actionchannels(ob->action, 1); /* swaps */
+       }
        
        allqueue(REDRAWBUTSEDIT, 0);
        allqueue(REDRAWBUTSOBJECT, 0);
index 952ae957f342e71ea532a56c7c4f02565ba4adad..9516f39b05c883e587a82f3d9b85d25d51bb68c0 100644 (file)
@@ -379,7 +379,7 @@ static EditFace *addface_from_edges(void)
        
        /* find the 4 edges */
        for(eed= em->edges.first; eed; eed= eed->next) {
-               if(eed->f & SELECT) {
+               if( (eed->f & SELECT) || (eed->v1->f & eed->v2->f & SELECT) ) {
                        if(eedar[0]==NULL) eedar[0]= eed;
                        else if(eedar[1]==NULL) eedar[1]= eed;
                        else if(eedar[2]==NULL) eedar[2]= eed;
@@ -765,6 +765,7 @@ void addedgeface_mesh(void)
                                /* if 4 edges exist, we just create the face, convex or not */
                                        efa= addface_from_edges();
                                        if(efa==NULL) {
+                                               
                                                /* the order of vertices can be anything, 6 cases to check */
                                                if( convex(neweve[0]->co, neweve[1]->co, neweve[2]->co, neweve[3]->co) ) {
                                                        efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], NULL, NULL);
@@ -775,17 +776,16 @@ void addedgeface_mesh(void)
                                                else if( convex(neweve[0]->co, neweve[2]->co, neweve[1]->co, neweve[3]->co) ) {
                                                        efa= addfacelist(neweve[0], neweve[2], neweve[1], neweve[3], NULL, NULL);
                                                }
-                                               
-                                               else if( convex(neweve[1]->co, neweve[2]->co, neweve[3]->co, neweve[0]->co) ) {
-                                                       efa= addfacelist(neweve[1], neweve[2], neweve[3], neweve[0], NULL, NULL);
+                                               else if( convex(neweve[0]->co, neweve[1]->co, neweve[3]->co, neweve[2]->co) ) {
+                                                       efa= addfacelist(neweve[0], neweve[1], neweve[3], neweve[2], NULL, NULL);
                                                }
-                                               else if( convex(neweve[1]->co, neweve[3]->co, neweve[0]->co, neweve[2]->co) ) {
-                                                       efa= addfacelist(neweve[1], neweve[3], neweve[0], neweve[2], NULL, NULL);
+                                               else if( convex(neweve[0]->co, neweve[3]->co, neweve[2]->co, neweve[1]->co) ) {
+                                                       efa= addfacelist(neweve[0], neweve[3], neweve[2], neweve[1], NULL, NULL);
                                                }
-                                               else if( convex(neweve[1]->co, neweve[3]->co, neweve[2]->co, neweve[0]->co) ) {
-                                                       efa= addfacelist(neweve[1], neweve[3], neweve[2], neweve[0], NULL, NULL);
+                                               else if( convex(neweve[0]->co, neweve[3]->co, neweve[1]->co, neweve[2]->co) ) {
+                                                       efa= addfacelist(neweve[0], neweve[3], neweve[1], neweve[2], NULL, NULL);
                                                }
-                                               else error("The selected vertices form a concave quad");
+                                               else printf("cannot find nice quad from concave set of vertices\n");
                                        }
                                }
                        }
index d758f34949a3249ffbde169faf3ce5c8472c3846..dbc0deecb2cae140def1e887f362347c3d67e03a 100644 (file)
@@ -501,26 +501,47 @@ static void set_active_strip(Object *ob, bActionStrip *act)
 {
        bActionStrip *strip;
        
+       /* make sure all other strips are not active */
        for (strip = ob->nlastrips.first; strip; strip=strip->next)
                strip->flag &= ~ACTSTRIP_ACTIVE;
        
-       if(act) {
+       /* act is new active strip */
+       if (act) {
+               /* set active flag for this strip */
                act->flag |= ACTSTRIP_ACTIVE;
-       
-               if(ob->action!=act->act) {
-                       if(ob->action) ob->action->id.us--;
-                       if(act->act->id.lib) {
+               
+               /* check if active action will still be the same one */
+               if (ob->action != act->act) {
+                       /* clear object's links with its current action (if present) */
+                       if (ob->action) {
+                               ob->action->id.us--;
+                       }
+                       
+                       /* only set object's action to active strip's action if possible */
+                       if (act->act->id.lib) {
                                ob->action= NULL;
                        }
                        else {
                                ob->action= act->act;
                                id_us_plus(&ob->action->id);
-                       }                       
+                       }       
+                       
+                       /* request redrawing in relevant spaces */
                        allqueue(REDRAWIPO, 0);
                        allqueue(REDRAWVIEW3D, 0);
                        allqueue(REDRAWACTION, 0);
                        allqueue(REDRAWNLA, 0);
-                       ob->ctime= -1234567.0f; // eveil! 
+                       
+                       /* when only showing action (i.e. nla-override off), 
+                        * reset pose to restpose for armatures 
+                        */
+                       if ((ob->nlaflag & OB_NLA_OVERRIDE)==0) {
+                               if (ob->type == OB_ARMATURE)
+                                       rest_pose(ob->pose);
+                       }
+                       
+                       /* flush depsgraph */
+                       ob->ctime= -1234567.0f; // evil! 
                        DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
                }
        }       
index 18a9803dcae088762e8b33efc54b3d7f82d345bb..69070d61bf0e6abab0de8eaab33656fabc65f5b1 100644 (file)
@@ -694,7 +694,7 @@ void mouse_select_sima(void)
        EditFace *efa;
        MTFace *tf, *nearesttf;
        EditFace *nearestefa=NULL;
-       int a, selectsticky, edgeloop, actface, nearestuv, nearestedge, i, shift;
+       int a, selectsticky, edgeloop, actface, nearestuv, nearestedge, i, shift, island=0;
        char sticky= 0;
        int flush = 0; /* 0 == dont flush, 1 == sel, -1 == desel;  only use when selection sync is enabled */
        unsigned int hitv[4], nearestv;
@@ -706,7 +706,7 @@ void mouse_select_sima(void)
        
        edgeloop= G.qual & LR_ALTKEY;
        shift= G.qual & LR_SHIFTKEY;
-
+       
        if (G.sima->flag & SI_SYNC_UVSEL) {
                /* copy from mesh */
                if (G.scene->selectmode == SCE_SELECT_FACE) {
@@ -718,7 +718,8 @@ void mouse_select_sima(void)
                }
        } else {
                /* normal operation */
-               actface= G.sima->flag & SI_SELACTFACE;
+               actface= G.sima->selectmode == SI_SELECT_FACE;
+               island= G.sima->selectmode == SI_SELECT_ISLAND;
                
                switch(G.sima->sticky) {
                case SI_STICKY_LOC:
@@ -760,6 +761,9 @@ void mouse_select_sima(void)
                
                if (nearestefa->v4)     hitv[3]= nearestefa->v4->tmp.l;
                else                            hitv[3]= 0xFFFFFFFF;
+       }
+       else if (island) {
+
        }
        else {
                find_nearest_uv(&nearesttf, &nearestefa, &nearestv, &nearestuv);
@@ -774,7 +778,11 @@ void mouse_select_sima(void)
                }
        }
 
-       if(!edgeloop && shift) {
+       if (island) {
+               if(shift) select_linked_tface_uv(1);
+               else select_linked_tface_uv(0);
+       }
+       else if(!edgeloop && shift) {
                /* (de)select face */
                if(actface) {
                        if(simaFaceSel_Check(nearestefa, nearesttf)) {
index 5a10ea65738256b9dfb857d0237f0ba7d77477c9..2c37a0eb20fec9c707289efc390bc68d4c5bb9c1 100644 (file)
@@ -803,11 +803,11 @@ static void timeline_force_draw(short val)
                if(sa->spacetype==SPACE_VIEW3D) {
                        if(sa==samin || (val & TIME_ALL_3D_WIN)) dodraw= 1;
                }
-               else if(ELEM6(sa->spacetype, SPACE_NLA, SPACE_IPO, SPACE_SEQ, SPACE_BUTS, SPACE_ACTION, SPACE_SOUND)) {
+               else if(ELEM5(sa->spacetype, SPACE_NLA, SPACE_IPO, SPACE_SEQ, SPACE_ACTION, SPACE_SOUND)) {
                        if(val & TIME_ALL_ANIM_WIN) dodraw= 1;
                }
                else if(sa->spacetype==SPACE_BUTS) {
-                       if(val & TIME_ALL_BUTS_WIN) dodraw= 1;
+                       if(val & TIME_ALL_BUTS_WIN) dodraw= 2;
                }
                else if(sa->spacetype==SPACE_IMAGE) {
                        if (val & TIME_ALL_IMAGE_WIN) dodraw = 1;
index 7ac57cb839b775cb6ea8fc7a7e822f23d6b585b9..fac9e3af1afaaab473257f4a7bd0e6794ac9ef19 100644 (file)
@@ -1214,28 +1214,31 @@ void image_buttons(void)
                        uiBlockBeginAlign(block);
                        
                        /* B_SEL_VERT & B_SEL_FACE are not defined here which is a bit bad, BUT it works even if image editor is fullscreen */
-                       uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode (Ctrl Tab 1)");
-                       xco+= XIC;
+                       uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL,
+                               xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode (Ctrl Tab 1)");
                        /* no edge */
                        /*uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode (Ctrl Tab 2)");
                        xco+= XIC; */
-                       uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode (Ctrl Tab 3)");
-                       xco+= XIC+8;
+                       uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL,
+                               xco+=XIC,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode (Ctrl Tab 3)");
                        uiBlockEndAlign(block);
                        
                } else {
                        uiBlockBeginAlign(block);
-                       uiDefIconButBitI(block, TOGN, SI_SELACTFACE, B_REDR, ICON_VERTEXSEL, xco,0,XIC,YIC, &G.sima->flag, 1.0, 0.0, 0, 0, "UV Vertex select mode");
-                       xco+= XIC;
-                       uiDefIconButBitI(block, TOG, SI_SELACTFACE, B_REDR, ICON_FACESEL, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "UV Face select mode");
-                       xco+= XIC+8;
-                       uiBlockEndAlign(block);
                        
+                       uiDefIconButS(block,  ROW, B_REDR, ICON_VERTEXSEL,
+                               xco,0,XIC,YIC, &G.sima->selectmode, 0.0, SI_SELECT_VERTEX, 0, 0, "UV vertex select mode");
+                       uiDefIconButS(block,  ROW, B_REDR, ICON_FACESEL,
+                               xco+=XIC,0,XIC,YIC, &G.sima->selectmode, 0.0, SI_SELECT_FACE, 0, 0, "UV Face select mode");
+                       uiDefIconButS(block,  ROW, B_REDR, ICON_MESH,
+                               xco+=XIC,0,XIC,YIC, &G.sima->selectmode, 0.0, SI_SELECT_ISLAND, 0, 0, "UV Island select mode");
+                       uiBlockEndAlign(block);
+
                        /* would use these if const's could go in strings 
                         * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */
                        ubut = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC,
                                        "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2",
-                                       xco,0,XIC+10,YIC, &(G.sima->sticky), 0, 3.0, 0, 0,
+                                       xco+=XIC+10,0,XIC+10,YIC, &(G.sima->sticky), 0, 3.0, 0, 0,
                                        "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)");
                        
                }
index 1ada2729289c345aed619b45e31aef143b479288..0f3a46c8a8cbb77e0df2e580cf8f380327c4c8b9 100644 (file)
@@ -1313,6 +1313,9 @@ static void do_view3d_select_armaturemenu(void *arg, int event)
                case 3: /* Select Parent(s) */  
                        select_bone_parent();
                        break;
+               case 4: /* Swap Select All */
+                       deselectall_armature(3, 1);
+                       break;
        }
        allqueue(REDRAWVIEW3D, 0);
 }
@@ -1331,6 +1334,8 @@ static uiBlock *view3d_select_armaturemenu(void *arg_unused)
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
        
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Swap Select All|Ctrl I",                 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
+       
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Parent(s)|P",                                     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
 
        if(curarea->headertype==HEADERTOP) {
@@ -1356,12 +1361,15 @@ static void do_view3d_select_pose_armaturemenu(void *arg, int event)
        case 2: /* Select/Deselect all */
                deselectall_posearmature(OBACT, 1, 1);
                break;
-       case 3:
+       case 3: /* Select Target(s) of Constraint(s) */
                pose_select_constraint_target();
                break;
-       case 4:
+       case 4: /* Select Bone's Parent */
                select_bone_parent();
                break;
+       case 5: /* Swap Select All */
+               deselectall_posearmature(OBACT, 3, 1);
+               break;
        }
        allqueue(REDRAWVIEW3D, 0);
 }
@@ -1379,6 +1387,7 @@ static uiBlock *view3d_select_pose_armaturemenu(void *arg_unused)
        uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Swap Select All|Ctrl I",                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Constraint Target|W",                     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Parent(s)|P",                                     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
 
@@ -4106,7 +4115,7 @@ static uiBlock *view3d_pose_armature_ikmenu(void *arg_unused)
        block= uiNewBlock(&curarea->uiblocks, "view3d_pose_armature_ikmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
        uiBlockSetButmFunc(block, do_view3d_pose_armature_ikmenu, NULL);
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add IK to Bone...|Ctrl I",                       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add IK to Bone...|Shift I",                      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear IK...|Alt I",                      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
        
        uiBlockSetDirection(block, UI_RIGHT);
index 6851929bbc21fff352acecbb7e61521640d6c5e3..9426548dc38c952be12b74fdb1506facb9cb7deb 100644 (file)
@@ -2380,6 +2380,16 @@ ImBuf *give_ibuf_seq(int rectx, int recty, int cfra, int chanshown)
        return i;
 }
 
+/* check used when we need to change seq->blend_mode but not to effect or audio strips */
+int seq_can_blend(Sequence *seq)
+{
+       if (ELEM4(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE)) {
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
 /* threading api */
 
 static ListBase running_threads;
index 4422411b1c57bb561d36d28af821d9f7425d6cab..3b8bb4c3929be8f152e2019288b34666d77fc701 100644 (file)
@@ -2189,10 +2189,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case IKEY:
                                if(G.qual==LR_CTRLKEY) {
-                                       if(ob && (ob->flag & OB_POSEMODE) && ob->type==OB_ARMATURE)
-                                               pose_add_IK();
-                                       else if(ob && G.obedit)
-                                               selectswap_mesh();
+                                       if((ob) && (ob->flag & OB_POSEMODE) && (ob->type==OB_ARMATURE))
+                                               deselectall_posearmature(ob, 3, 1);
+                                       else if(ob && G.obedit) {
+                                               if(G.obedit->type == OB_ARMATURE)
+                                                       deselectall_armature(3, 1);
+                                               else
+                                                       selectswap_mesh();
+                                       }
                                        else
                                                selectswap();
                                }
@@ -2200,6 +2204,10 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        if(ob && (ob->flag & OB_POSEMODE) && ob->type==OB_ARMATURE)
                                                pose_clear_IK();
                                }
+                               else if(G.qual==LR_SHIFTKEY) {
+                                       if(ob && (ob->flag & OB_POSEMODE) && ob->type==OB_ARMATURE)
+                                               pose_add_IK();
+                               }
                                break;
                                
                        case JKEY:
@@ -4432,7 +4440,10 @@ static void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
 
                switch(event) {
                case UI_BUT_EVENT:
-                       if(val==REDRAWTIME) allqueue(REDRAWTIME, 0);
+                       if(val==REDRAWTIME) {
+                               allqueue(REDRAWTIME, 0);
+                               addqueue(sa->win, REDRAW, 1);
+                       }
                        else if(val==B_ADD_THEME) {
                                bTheme *btheme, *new;
                                
index dcebf6b75578351cd5231cecd1fa2f44b05a3fa2..10e49cdd2183eb6ad80565a9ee7de8d09cc28b82 100644 (file)
@@ -3610,6 +3610,7 @@ void special_aftertrans_update(TransInfo *t)
        Base *base;
        short redrawipo=0, resetslowpar=1;
        int cancelled= (t->state == TRANS_CANCEL);
+       short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0;
        
        if (t->spacetype==SPACE_VIEW3D) {
                if (G.obedit) {
@@ -3622,7 +3623,7 @@ void special_aftertrans_update(TransInfo *t)
                        }
                }
        }
-       if (t->spacetype == SPACE_ACTION) {
+       else if (t->spacetype == SPACE_ACTION) {
                void *data;
                short datatype;
                
@@ -3644,7 +3645,7 @@ void special_aftertrans_update(TransInfo *t)
                        
                        /* Do curve cleanups? */
                        if ( (G.saction->flag & SACTION_NOTRANSKEYCULL)==0 && 
-                            (cancelled == 0) )
+                            ((cancelled == 0) || (duplicate)) )
                        {
                                posttrans_action_clean((bAction *)data);
                        }
@@ -3659,7 +3660,7 @@ void special_aftertrans_update(TransInfo *t)
                                IpoCurve *icu;
                                
                                if ( (G.saction->flag & SACTION_NOTRANSKEYCULL)==0 && 
-                                    (cancelled == 0) )
+                                    ((cancelled == 0) || (duplicate)) )
                                {
                                        posttrans_ipo_clean(key->ipo);
                                }
@@ -3685,7 +3686,7 @@ void special_aftertrans_update(TransInfo *t)
                
                /* after transform, remove duplicate keyframes on a frame that resulted from transform */
                if ( (G.snla->flag & SNLA_NOTRANSKEYCULL)==0 && 
-                        (cancelled == 0) )
+                        ((cancelled == 0) || (duplicate)) )
                {
                        posttrans_nla_clean(t);
                }
index 2a4672e3052268b30c109e2f8414f4d5798e829a..4aea0df74b909ca2c89391a27c0d6fed26e5232a 100644 (file)
@@ -34,6 +34,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "GL/glew.h"
+
 #ifdef WIN32
 #include <windows.h> /* need to include windows.h so _WIN32_IE is defined  */
 #ifndef _WIN32_IE
index f457f9203fffa17b6c02658b18c30427c9e732f2..12450bee9defebb9deb26afa9a6c4acfc1b1fc4c 100644 (file)
@@ -1154,7 +1154,7 @@ void viewmoveNDOF(int mode)
     float q1[4];
     float obofs[3];
     float reverse;
-    float diff[4];
+    //float diff[4];
     float d, curareaX, curareaY;
     float mat[3][3];
     float upvec[3];
index 4e883caba5569f303e7f41174bee2eb6abc0f327..935c546a23544f6fb57c67768d42fbec1759179c 100644 (file)
@@ -566,9 +566,9 @@ static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
        cp=  (char *)&col;
        
        cp[0]= 255;
-       cp[1]= (mfac*cp1[1]+fac*cp2[1])>>8;
-       cp[2]= (mfac*cp1[2]+fac*cp2[2])>>8;
-       cp[3]= (mfac*cp1[3]+fac*cp2[3])>>8;
+       cp[1]= (mfac*cp1[1]+fac*cp2[1])/255;
+       cp[2]= (mfac*cp1[2]+fac*cp2[2])/255;
+       cp[3]= (mfac*cp1[3]+fac*cp2[3])/255;
        
        return col;
 }
@@ -586,11 +586,11 @@ static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
        cp=  (char *)&col;
        
        cp[0]= 255;
-       temp= cp1[1] + ((fac*cp2[1])>>8);
+       temp= cp1[1] + ((fac*cp2[1])/255);
        if(temp>254) cp[1]= 255; else cp[1]= temp;
-       temp= cp1[2] + ((fac*cp2[2])>>8);
+       temp= cp1[2] + ((fac*cp2[2])/255);
        if(temp>254) cp[2]= 255; else cp[2]= temp;
-       temp= cp1[3] + ((fac*cp2[3])>>8);
+       temp= cp1[3] + ((fac*cp2[3])/255);
        if(temp>254) cp[3]= 255; else cp[3]= temp;
        
        return col;
@@ -609,11 +609,11 @@ static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
        cp=  (char *)&col;
        
        cp[0]= 255;
-       temp= cp1[1] - ((fac*cp2[1])>>8);
+       temp= cp1[1] - ((fac*cp2[1])/255);
        if(temp<0) cp[1]= 0; else cp[1]= temp;
-       temp= cp1[2] - ((fac*cp2[2])>>8);
+       temp= cp1[2] - ((fac*cp2[2])/255);
        if(temp<0) cp[2]= 0; else cp[2]= temp;
-       temp= cp1[3] - ((fac*cp2[3])>>8);
+       temp= cp1[3] - ((fac*cp2[3])/255);
        if(temp<0) cp[3]= 0; else cp[3]= temp;
        
        return col;
@@ -635,9 +635,9 @@ static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
        
        /* first mul, then blend the fac */
        cp[0]= 255;
-       cp[1]= (mfac*cp1[1] + fac*((cp2[1]*cp1[1])>>8)  )>>8;
-       cp[2]= (mfac*cp1[2] + fac*((cp2[2]*cp1[2])>>8)  )>>8;
-       cp[3]= (mfac*cp1[3] + fac*((cp2[3]*cp1[3])>>8)  )>>8;
+       cp[1]= (mfac*cp1[1] + fac*((cp2[1]*cp1[1])/255)  )/255;
+       cp[2]= (mfac*cp1[2] + fac*((cp2[2]*cp1[2])/255)  )/255;
+       cp[3]= (mfac*cp1[3] + fac*((cp2[3]*cp1[3])/255)  )/255;
 
        
        return col;
@@ -664,9 +664,9 @@ static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
                return col1;
        
        cp[0]= 255;
-       cp[1]= (mfac*cp1[1]+fac*cp2[1])>>8;
-       cp[2]= (mfac*cp1[2]+fac*cp2[2])>>8;
-       cp[3]= (mfac*cp1[3]+fac*cp2[3])>>8;
+       cp[1]= (mfac*cp1[1]+fac*cp2[1])/255;
+       cp[2]= (mfac*cp1[2]+fac*cp2[2])/255;
+       cp[3]= (mfac*cp1[3]+fac*cp2[3])/255;
        
        return col;
 }
@@ -692,9 +692,9 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
                return col1;
        
        cp[0]= 255;
-       cp[1]= (mfac*cp1[1]+fac*cp2[1])>>8;
-       cp[2]= (mfac*cp1[2]+fac*cp2[2])>>8;
-       cp[3]= (mfac*cp1[3]+fac*cp2[3])>>8;
+       cp[1]= (mfac*cp1[1]+fac*cp2[1])/255;
+       cp[2]= (mfac*cp1[2]+fac*cp2[2])/255;
+       cp[3]= (mfac*cp1[3]+fac*cp2[3])/255;
        return col;
 }
 
index 230d6b262c6b3e6c5f92509022cd88bb76c8d2d3..ed6ea7c5f6ae6b2bc52b59cc2e6751ba70183a29 100644 (file)
@@ -26,6 +26,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include "GL/glew.h"
 #include "KX_BlenderGL.h"
 
 #ifdef HAVE_CONFIG_H
@@ -44,7 +45,6 @@
 
 #include "BMF_Api.h"
 
-#include "GL/glew.h"
 #include "BIF_gl.h"
 
 #include "BL_Material.h" // MAXTEX
index 44f6ec1af90b08820ea1c9ba530b1df24576aa1c..5d6dd694765241c8ab204692a5dd8d94ccee3af6 100644 (file)
@@ -184,6 +184,11 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
                
                if (bNegativeEvent)
                {
+                       // dont continue where we left off when restarting
+                       if (m_end_reset) {
+                               m_flag &= ~ACT_FLAG_LOCKINPUT;
+                       }
+                       
                        if (!(m_flag & ACT_FLAG_ACTIVE))
                                return false;
                        m_flag &= ~ACT_FLAG_ACTIVE;
@@ -472,8 +477,10 @@ PyMethodDef BL_ActionActuator::Methods[] = {
        {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, GetFrameProperty_doc},
        {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc},
 //     {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
-       {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc},    
+       {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc},
        {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, SetType_doc},
+       {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},       
+       {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
        {NULL,NULL} //Sentinel
 };
 
@@ -978,7 +985,26 @@ PyObject* BL_ActionActuator::PySetType(PyObject* self,
        default:
                printf("Invalid type for action actuator: %d\n", typeArg); /* error */
     }
+       Py_RETURN_NONE;
+}
+
+PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
+    return PyInt_FromLong((long)(m_end_reset==0));
+}
+
+PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
+       int param = PyObject_IsTrue( value );
        
-    Py_Return;
+       if( param == -1 ) {
+               PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
+               return NULL;
+       }
+
+       if (param) {
+               m_end_reset = 0;
+       } else {
+               m_end_reset = 1;
+       }
+    Py_RETURN_NONE;
 }
 
index 190f727c9c3eb5b8a7b7062432295ed5bc626de7..a67b6d29b7453abdc366916f12467cfcc927da1a 100644 (file)
@@ -47,6 +47,7 @@ public:
                                                short   playtype,
                                                short   blendin,
                                                short   priority,
+                                               short   end_reset,
                                                float   stride,
                                                PyTypeObject* T=&Type) 
                : SCA_IActuator(gameobj,T),
@@ -64,6 +65,7 @@ public:
                m_stridelength(stride),
                m_playtype(playtype),
                m_priority(priority),
+               m_end_reset(end_reset),
                m_pose(NULL),
                m_blendpose(NULL),
                m_userpose(NULL),
@@ -101,6 +103,8 @@ public:
 //     KX_PYMETHOD(BL_ActionActuator,GetChannel);
        KX_PYMETHOD_DOC(BL_ActionActuator,GetType);
        KX_PYMETHOD_DOC(BL_ActionActuator,SetType);
+       KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue);
+       KX_PYMETHOD_O(BL_ActionActuator,SetContinue);
 
        virtual PyObject* _getattr(const STR_String& attr);
 
@@ -137,6 +141,7 @@ protected:
        float   m_stridelength;
        short   m_playtype;
        short   m_priority;
+       short   m_end_reset;
        struct bPose* m_pose;
        struct bPose* m_blendpose;
        struct bPose* m_userpose;
index 665783a1ba51ac9f5ed50a3022a143e774f1aa6b..f3e22cd297a0a6eaedad6791dde51a479bc4ed17 100644 (file)
@@ -312,11 +312,13 @@ BL_Material* ConvertMaterial(
        Mesh* mesh, 
        Material *mat, 
        MTFace* tface,  
+       const char *tfaceName,
        MFace* mface, 
        MCol* mmcol, 
        int lightlayer, 
        Object* blenderobj,
-       MTF_localLayer *layers)
+       MTF_localLayer *layers,
+       bool glslmat)
 {
        //this needs some type of manager
        BL_Material *material = new BL_Material();
@@ -335,7 +337,7 @@ BL_Material* ConvertMaterial(
        if(validmat) {
 
                // use vertex colors by explicitly setting
-               if(mat->mode &MA_VERTEXCOLP)
+               if(mat->mode &MA_VERTEXCOLP || glslmat)
                        type = 0;
 
                // use lighting?
@@ -558,6 +560,7 @@ BL_Material* ConvertMaterial(
        }
        else {
                int valid = 0;
+
                // check for tface tex to fallback on
                if( validface ){
 
@@ -590,6 +593,7 @@ BL_Material* ConvertMaterial(
        }
        MT_Point2 uv[4];
        MT_Point2 uv2[4];
+       const char *uvName = "", *uv2Name = "";
 
        uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f);
        uv2[0]= uv2[1]= uv2[2]= uv2[3]= MT_Point2(0.0f, 0.0f);
@@ -616,6 +620,8 @@ BL_Material* ConvertMaterial(
 
                if (mface->v4) 
                        uv[3]   = MT_Point2(tface->uv[3]);
+
+               uvName = tfaceName;
        } 
        else {
                // nothing at all
@@ -641,39 +647,38 @@ BL_Material* ConvertMaterial(
                                isFirstSet = false;
                        else
                        {
-                               MT_Point2 uvSet[4];
                                for (int lay=0; lay<MAX_MTFACE; lay++)
                                {
                                        MTF_localLayer& layer = layers[lay];
                                        if (layer.face == 0) break;
 
-
-                                       bool processed = false;
                                        if (strcmp(map.uvCoName.ReadPtr(), layer.name)==0)
                                        {
+                                               MT_Point2 uvSet[4];
+
                                                uvSet[0]        = MT_Point2(layer.face->uv[0]);
                                                uvSet[1]        = MT_Point2(layer.face->uv[1]);
                                                uvSet[2]        = MT_Point2(layer.face->uv[2]);
 
                                                if (mface->v4) 
                                                        uvSet[3]        = MT_Point2(layer.face->uv[3]);
+                                               else
+                                                       uvSet[3]        = MT_Point2(0.0f, 0.0f);
 
-                                               processed = true;
-                                       }
-
-                                       if (!processed) continue;
-
-                                       if (isFirstSet)
-                                       {
-                                               uv[0] = uvSet[0]; uv[1] = uvSet[1];
-                                               uv[2] = uvSet[2]; uv[3] = uvSet[3];
-                                               isFirstSet = false;
-                                       }
-                                       else
-                                       {
-                                               uv2[0] = uvSet[0]; uv2[1] = uvSet[1];
-                                               uv2[2] = uvSet[2]; uv2[3] = uvSet[3];
-                                               map.mapping |= USECUSTOMUV;
+                                               if (isFirstSet)
+                                               {
+                                                       uv[0] = uvSet[0]; uv[1] = uvSet[1];
+                                                       uv[2] = uvSet[2]; uv[3] = uvSet[3];
+                                                       isFirstSet = false;
+                                                       uvName = layer.name;
+                                               }
+                                               else
+                                               {
+                                                       uv2[0] = uvSet[0]; uv2[1] = uvSet[1];
+                                                       uv2[2] = uvSet[2]; uv2[3] = uvSet[3];
+                                                       map.mapping |= USECUSTOMUV;
+                                                       uv2Name = layer.name;
+                                               }
                                        }
                                }
                        }
@@ -693,9 +698,8 @@ BL_Material* ConvertMaterial(
        }
 
        material->SetConversionRGB(rgb);
-       material->SetConversionUV(uv);
-       material->SetConversionUV2(uv2);
-
+       material->SetConversionUV(uvName, uv);
+       material->SetConversionUV2(uv2Name, uv2);
 
        material->ras_mode |= (mface->v4==0)?TRIANGLE:0;
        if(validmat)
@@ -797,6 +801,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
        
        MFace* mface = static_cast<MFace*>(mesh->mface);
        MTFace* tface = static_cast<MTFace*>(mesh->mtface);
+       const char *tfaceName = "";
        MCol* mmcol = mesh->mcol;
        MT_assert(mface || mesh->totface == 0);
 
@@ -832,14 +837,14 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
 
                        layers[validLayers].face = (MTFace*)mesh->fdata.layers[i].data;;
                        layers[validLayers].name = mesh->fdata.layers[i].name;
+                       if(tface == layers[validLayers].face)
+                               tfaceName = layers[validLayers].name;
                        validLayers++;
                }
        }
 
        meshobj->SetName(mesh->id.name);
        meshobj->m_xyz_index_to_vertex_index_mapping.resize(mesh->totvert);
-       if(skinMesh)
-               ((BL_SkinMeshObject*)meshobj)->m_mvert_to_dvert_mapping.resize(mesh->totvert);
        for (int f=0;f<mesh->totface;f++,mface++)
        {
                
@@ -898,8 +903,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
                                        else 
                                                ma = give_current_material(blenderobj, 1);
 
-                                       bl_mat = ConvertMaterial(mesh, ma, tface, mface, mmcol, lightlayer, blenderobj, layers);
-                                       bl_mat->glslmat = converter->GetGLSLMaterials();
+                                       bl_mat = ConvertMaterial(mesh, ma, tface, tfaceName, mface, mmcol, lightlayer, blenderobj, layers, converter->GetGLSLMaterials());
                                        // set the index were dealing with
                                        bl_mat->material_index =  (int)mface->mat_nr;
 
@@ -1059,35 +1063,25 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
                                int nverts = mface->v4?4:3;
                                int vtxarray = meshobj->FindVertexArray(nverts,polymat);
                                RAS_Polygon* poly = new RAS_Polygon(bucket,polyvisible,nverts,vtxarray);
-                               if (skinMesh) {
-                                       int d1, d2, d3, d4=0;
-                                       bool flat;
 
+                               bool flat;
+
+                               if (skinMesh) {
                                        /* If the face is set to solid, all fnors are the same */
                                        if (mface->flag & ME_SMOOTH)
                                                flat = false;
                                        else
                                                flat = true;
-                                       
-                                       d1=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v1, &mesh->dvert[mface->v1], polymat);
-                                       d2=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v2, &mesh->dvert[mface->v2], polymat);
-                                       d3=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v3, &mesh->dvert[mface->v3], polymat);
-                                       if (nverts==4)
-                                               d4=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v4, &mesh->dvert[mface->v4], polymat);
-                                       poly->SetVertex(0,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,d1,flat,polymat,mface->v1));
-                                       poly->SetVertex(1,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,d2,flat,polymat,mface->v2));
-                                       poly->SetVertex(2,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,d3,flat,polymat,mface->v3));
-                                       if (nverts==4)
-                                               poly->SetVertex(3,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,d4,flat,polymat,mface->v4));
                                }
                                else
-                               {
-                                       poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,false,polymat,mface->v1));
-                                       poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,false,polymat,mface->v2));
-                                       poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,false,polymat,mface->v3));
-                                       if (nverts==4)
-                                               poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,false,polymat,mface->v4));
-                               }
+                                       flat = false;
+
+                               poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,flat,polymat,mface->v1));
+                               poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,flat,polymat,mface->v2));
+                               poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,flat,polymat,mface->v3));
+                               if (nverts==4)
+                                       poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,flat,polymat,mface->v4));
+
                                meshobj->AddPolygon(poly);
                                if (poly->IsCollider())
                                {
@@ -1125,8 +1119,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
                }
        }
        meshobj->m_xyz_index_to_vertex_index_mapping.clear();
-       if(skinMesh)
-               ((BL_SkinMeshObject*)meshobj)->m_mvert_to_dvert_mapping.clear();
        meshobj->UpdateMaterialList();
 
        // pre calculate texture generation
@@ -1545,7 +1537,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
 
 
 
-static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) {
+static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) {
        RAS_LightObject lightobj;
        KX_LightObject *gamelight;
        
@@ -1577,8 +1569,15 @@ static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX
        } else {
                lightobj.m_type = RAS_LightObject::LIGHT_NORMAL;
        }
+
+#ifdef BLENDER_GLSL
+       if(converter->GetGLSLMaterials())
+               GPU_lamp_from_blender(ob, la);
        
-       gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj);
+       gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, ob->gpulamp);
+#else
+       gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, NULL);
+#endif
        BL_ConvertLampIpos(la, gamelight, converter);
        
        return gamelight;
@@ -1610,7 +1609,7 @@ static KX_GameObject *gameobject_from_blenderobject(
        {
        case OB_LAMP:
        {
-               KX_LightObject* gamelight= gamelight_from_blamp(static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter);
+               KX_LightObject* gamelight= gamelight_from_blamp(ob, static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter);
                gameobj = gamelight;
                
                gamelight->AddRef();
@@ -1660,7 +1659,7 @@ static KX_GameObject *gameobject_from_blenderobject(
                // two options exists for deform: shape keys and armature
                // only support relative shape key
                bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE;
-               bool bHasDvert = mesh->dvert != NULL;
+               bool bHasDvert = mesh->dvert != NULL && ob->defbase.first;
                bool bHasArmature = (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && bHasDvert);
 
                if (bHasShapeKey) {
@@ -1671,13 +1670,15 @@ static KX_GameObject *gameobject_from_blenderobject(
                        if (bHasArmature)
                                dcont->LoadShapeDrivers(ob->parent);
                } else if (bHasArmature) {
-                       BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj );                         
+                       BL_SkinDeformer *dcont = new BL_SkinDeformer((BL_DeformableGameObject*)gameobj,
+                                                                                                                       ob, (BL_SkinMeshObject*)meshobj);
                        ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont;
                } else if (bHasDvert) {
                        // this case correspond to a mesh that can potentially deform but not with the
                        // object to which it is attached for the moment. A skin mesh was created in
                        // BL_ConvertMesh() so must create a deformer too!
-                       BL_MeshDeformer *dcont = new BL_MeshDeformer(ob, (BL_SkinMeshObject*)meshobj );
+                       BL_MeshDeformer *dcont = new BL_MeshDeformer((BL_DeformableGameObject*)gameobj,
+                                                                                                                 ob, (BL_SkinMeshObject*)meshobj);
                        ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont;
                }
                
@@ -2075,7 +2076,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
        if (blenderscene->camera) {
                KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera);
                
-               kxscene->SetActiveCamera(gamecamera);
+               if(gamecamera)
+                       kxscene->SetActiveCamera(gamecamera);
        }
 
        //      Set up armatures
@@ -2331,7 +2333,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
        {
                KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
                struct Object* blenderobj = converter->FindBlenderObject(gameobj);
-               gameobj->SetState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state);
+               gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state);
+               gameobj->ResetState();
        }
 
 #endif //CONVERT_LOGIC
index 212827a660f746ab47c24623a62e6801c6d5f52e..39d66a90e927d5afa6d87e2c457af5c0a871c2a3 100644 (file)
@@ -39,6 +39,7 @@
 #endif
 
 #include "RAS_IPolygonMaterial.h"
+#include "BL_DeformableGameObject.h"
 #include "BL_MeshDeformer.h"
 #include "BL_SkinMeshObject.h"
 #include "DNA_mesh_types.h"
 #include "GEN_Map.h"
 #include "STR_HashedString.h"
 
-bool BL_MeshDeformer::Apply(RAS_IPolyMaterial *mat)
+bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*)
 {
-       size_t                  i, j, index;
-       vecVertexArray  array;
-       vecIndexArrays  mvarray;
-       vecIndexArrays  diarray;
-
-       RAS_TexVert *tv;
-       MVert   *mvert;
-
-       // For each material
-       array = m_pMeshObject->GetVertexCache(mat);
-       mvarray = m_pMeshObject->GetMVertCache(mat);
-       diarray = m_pMeshObject->GetDIndexCache(mat);
-
-       // For each array
-       for (i=0; i<array.size(); i++){
-               //      For each vertex
-               for (j=0; j<array[i]->size(); j++){
-                       tv = &((*array[i])[j]);
-                       index = ((*diarray[i])[j]);
-
-                       mvert = &(m_bmesh->mvert[((*mvarray[i])[index])]);
-                       tv->SetXYZ(MT_Point3(mvert->co));
+       size_t i, j;
+       float *co;
+
+       // only apply once per frame if the mesh is actually modified
+       if(m_pMeshObject->MeshModified() &&
+          m_lastDeformUpdate != m_gameobj->GetLastFrame()) {
+               // For each material
+               for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial();
+                       mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
+                       RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial();
+
+                       vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat);
+
+                       // For each array
+                       for (i=0; i<vertexarrays.size(); i++){
+                               KX_VertexArray& vertexarray = (*vertexarrays[i]);
+
+                               //      For each vertex
+                               for (j=0; j<vertexarray.size(); j++){
+                                       RAS_TexVert& v = vertexarray[j];
+                                       co = m_bmesh->mvert[v.getOrigIndex()].co;
+                                       v.SetXYZ(MT_Point3(co));
+                               }
+                       }
                }
+
+               m_lastDeformUpdate = m_gameobj->GetLastFrame();
+
+               return true;
        }
-       return true;
+
+       return false;
 }
 
 BL_MeshDeformer::~BL_MeshDeformer()
@@ -92,83 +100,86 @@ void BL_MeshDeformer::RecalcNormals()
        /* We don't normalize for performance, not doing it for faces normals
         * gives area-weight normals which often look better anyway, and use
         * GL_NORMALIZE so we don't have to do per vertex normalization either
-        * since the GPU can do it faster
-        *
-        * There's a lot of indirection here to get to the data, can this work
-        * with less arrays/indirection? */
-
-       vecIndexArrays indexarrays;
-       vecIndexArrays mvarrays;
-       vecIndexArrays diarrays;
-       vecVertexArray vertexarrays;
+        * since the GPU can do it faster */
        size_t i, j;
 
        /* set vertex normals to zero */
-       for (i=0; i<(size_t)m_bmesh->totvert; i++)
-               m_transnors[i] = MT_Vector3(0.0f, 0.0f, 0.0f);
+       memset(m_transnors, 0, sizeof(float)*3*m_bmesh->totvert);
 
        /* add face normals to vertices. */
        for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial();
                mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
                RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial();
 
-               indexarrays = m_pMeshObject->GetIndexCache(mat);
-               vertexarrays = m_pMeshObject->GetVertexCache(mat);
-               diarrays = m_pMeshObject->GetDIndexCache(mat);
-               mvarrays = m_pMeshObject->GetMVertCache(mat);
+               const vecIndexArrays& indexarrays = m_pMeshObject->GetIndexCache(mat);
+               vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat);
 
                for (i=0; i<indexarrays.size(); i++) {
                        KX_VertexArray& vertexarray = (*vertexarrays[i]);
-                       const KX_IndexArray& mvarray = (*mvarrays[i]);
-                       const KX_IndexArray& diarray = (*diarrays[i]);
                        const KX_IndexArray& indexarray = (*indexarrays[i]);
                        int nvert = mat->UsesTriangles()? 3: 4;
 
                        for(j=0; j<indexarray.size(); j+=nvert) {
-                               MT_Point3 mv1, mv2, mv3, mv4, fnor;
-                               int i1 = indexarray[j];
-                               int i2 = indexarray[j+1];
-                               int i3 = indexarray[j+2];
-                               RAS_TexVert& v1 = vertexarray[i1];
-                               RAS_TexVert& v2 = vertexarray[i2];
-                               RAS_TexVert& v3 = vertexarray[i3];
-
+                               RAS_TexVert& v1 = vertexarray[indexarray[j]];
+                               RAS_TexVert& v2 = vertexarray[indexarray[j+1]];
+                               RAS_TexVert& v3 = vertexarray[indexarray[j+2]];
+                               RAS_TexVert *v4 = NULL;
+
+                               const float *co1 = v1.getLocalXYZ();
+                               const float *co2 = v2.getLocalXYZ();
+                               const float *co3 = v3.getLocalXYZ();
+                               const float *co4 = NULL;
+                               
                                /* compute face normal */
-                               mv1 = MT_Point3(v1.getLocalXYZ());
-                               mv2 = MT_Point3(v2.getLocalXYZ());
-                               mv3 = MT_Point3(v3.getLocalXYZ());
+                               float fnor[3], n1[3], n2[3];
 
                                if(nvert == 4) {
-                                       int i4 = indexarray[j+3];
-                                       RAS_TexVert& v4 = vertexarray[i4];
-                                       mv4 = MT_Point3(v4.getLocalXYZ());
+                                       v4 = &vertexarray[indexarray[j+3]];
+                                       co4 = v4->getLocalXYZ();
+
+                                       n1[0]= co1[0]-co3[0];
+                                       n1[1]= co1[1]-co3[1];
+                                       n1[2]= co1[2]-co3[2];
 
-                                       fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))); //.safe_normalized();
+                                       n2[0]= co2[0]-co4[0];
+                                       n2[1]= co2[1]-co4[1];
+                                       n2[2]= co2[2]-co4[2];
                                }
-                               else
-                                       fnor = ((mv2-mv1).cross(mv3-mv2)); //.safe_normalized();
+                               else {
+                                       n1[0]= co1[0]-co2[0];
+                                       n2[0]= co2[0]-co3[0];
+                                       n1[1]= co1[1]-co2[1];
+
+                                       n2[1]= co2[1]-co3[1];
+                                       n1[2]= co1[2]-co2[2];
+                                       n2[2]= co2[2]-co3[2];
+                               }
+
+                               fnor[0]= n1[1]*n2[2] - n1[2]*n2[1];
+                               fnor[1]= n1[2]*n2[0] - n1[0]*n2[2];
+                               fnor[2]= n1[0]*n2[1] - n1[1]*n2[0];
 
                                /* add to vertices for smooth normals */
-                               m_transnors[mvarray[diarray[i1]]] += fnor;
-                               m_transnors[mvarray[diarray[i2]]] += fnor;
-                               m_transnors[mvarray[diarray[i3]]] += fnor;
+                               float *vn1 = m_transnors[v1.getOrigIndex()];
+                               float *vn2 = m_transnors[v2.getOrigIndex()];
+                               float *vn3 = m_transnors[v3.getOrigIndex()];
+
+                               vn1[0] += fnor[0]; vn1[1] += fnor[1]; vn1[2] += fnor[2];
+                               vn2[0] += fnor[0]; vn2[1] += fnor[1]; vn2[2] += fnor[2];
+                               vn3[0] += fnor[0]; vn3[1] += fnor[1]; vn3[2] += fnor[2];
+
+                               if(v4) {
+                                       float *vn4 = m_transnors[v4->getOrigIndex()];
+                                       vn4[0] += fnor[0]; vn4[1] += fnor[1]; vn4[2] += fnor[2];
+                               }
 
                                /* in case of flat - just assign, the vertices are split */
                                if(v1.getFlag() & TV_CALCFACENORMAL) {
                                        v1.SetNormal(fnor);
                                        v2.SetNormal(fnor);
                                        v3.SetNormal(fnor);
-                               }
-
-                               if(nvert == 4) {
-                                       int i4 = indexarray[j+3];
-                                       RAS_TexVert& v4 = vertexarray[i4];
-
-                                       /* same as above */
-                                       m_transnors[mvarray[diarray[i4]]] += fnor;
-
-                                       if(v4.getFlag() & TV_CALCFACENORMAL)
-                                               v4.SetNormal(fnor);
+                                       if(v4)
+                                               v4->SetNormal(fnor);
                                }
                        }
                }
@@ -179,18 +190,17 @@ void BL_MeshDeformer::RecalcNormals()
                mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
                RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial();
 
-               vertexarrays = m_pMeshObject->GetVertexCache(mat);
-               diarrays = m_pMeshObject->GetDIndexCache(mat);
-               mvarrays = m_pMeshObject->GetMVertCache(mat);
+               vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat);
 
                for (i=0; i<vertexarrays.size(); i++) {
                        KX_VertexArray& vertexarray = (*vertexarrays[i]);
-                       const KX_IndexArray& mvarray = (*mvarrays[i]);
-                       const KX_IndexArray& diarray = (*diarrays[i]);
                        
-                       for(j=0; j<vertexarray.size(); j++)
-                               if(!(vertexarray[j].getFlag() & TV_CALCFACENORMAL))
-                                       vertexarray[j].SetNormal(m_transnors[mvarray[diarray[j]]]); //.safe_normalized()
+                       for(j=0; j<vertexarray.size(); j++) {
+                               RAS_TexVert& v = vertexarray[j];
+
+                               if(!(v.getFlag() & TV_CALCFACENORMAL))
+                                       v.SetNormal(m_transnors[v.getOrigIndex()]); //.safe_normalized()
+                       }
                }
        }
 }
@@ -204,8 +214,8 @@ void BL_MeshDeformer::VerifyStorage()
                if (m_transnors)
                        delete [] m_transnors;
                
-               m_transverts=new float[(sizeof(*m_transverts)*m_bmesh->totvert)][3];
-               m_transnors=new MT_Vector3[m_bmesh->totvert];
+               m_transverts=new float[m_bmesh->totvert][3];
+               m_transnors=new float[m_bmesh->totvert][3];
                m_tvtot = m_bmesh->totvert;
        }
 }
index 8d8b56b1eed33a0fbe5ef63f8e816cbcd530035e..e9f7f0b192fc5004f297ece28c327db99f3ec848 100644 (file)
 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
 #endif //WIN32
 
+class BL_DeformableGameObject;
+
 class BL_MeshDeformer : public RAS_Deformer
 {
 public:
        void VerifyStorage();
        void RecalcNormals();
        virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map){};
-       BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj ):
+       BL_MeshDeformer(BL_DeformableGameObject *gameobj,
+                                       struct Object* obj,
+                                       class BL_SkinMeshObject *meshobj ):
                m_pMeshObject(meshobj),
                m_bmesh((struct Mesh*)(obj->data)),
                m_transverts(0),
                m_transnors(0),
                m_objMesh(obj),
-               m_tvtot(0)
+               m_tvtot(0),
+               m_gameobj(gameobj),
+               m_lastDeformUpdate(-1)
        {};
        virtual ~BL_MeshDeformer();
        virtual void SetSimulatedTime(double time){};
@@ -68,10 +74,12 @@ protected:
        // this is so m_transverts doesn't need to be converted
        // before deformation
        float                                           (*m_transverts)[3];
-       MT_Vector3*                                     m_transnors;
+       float                                           (*m_transnors)[3];
        struct Object*                          m_objMesh; 
        // --
        int                                                     m_tvtot;
+       BL_DeformableGameObject*        m_gameobj;
+       double                                          m_lastDeformUpdate;
 };
 
 #endif
index 9f8361dbaca58371e0e8703861cab92411be2789..5f0188e3a42e145be2d4c24c1fe817a62bbfeb5b 100644 (file)
@@ -58,9 +58,8 @@ public:
                      Object *bmeshobj,
                      BL_SkinMeshObject *mesh)
                                        :       
-                                               BL_SkinDeformer(bmeshobj, mesh),
-                                               m_lastShapeUpdate(-1),
-                                               m_gameobj(gameobj)
+                                               BL_SkinDeformer(gameobj,bmeshobj, mesh),
+                                               m_lastShapeUpdate(-1)
        {
        };
 
@@ -72,9 +71,8 @@ public:
                                        bool release_object,
                                        BL_ArmatureObject* arma = NULL)
                                        :
-                                               BL_SkinDeformer(bmeshobj_old, bmeshobj_new, mesh, release_object, arma),
-                                               m_lastShapeUpdate(-1),
-                                               m_gameobj(gameobj)
+                                               BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, arma),
+                                               m_lastShapeUpdate(-1)
        {
        };
 
@@ -94,7 +92,6 @@ public:
 protected:
        vector<IpoCurve*>                m_shapeDrivers;
        double                                   m_lastShapeUpdate;
-       BL_DeformableGameObject* m_gameobj;
 
 };
 
index dd7119b10317162ab04c334222d37c3c80a89ca9..d3442fe529811a2858333496e93afebf4520bc01 100644 (file)
@@ -57,11 +57,12 @@ extern "C"{
 #define __NLA_DEFNORMALS
 //#undef __NLA_DEFNORMALS
 
-BL_SkinDeformer::BL_SkinDeformer(struct Object *bmeshobj, 
+BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+                                                               struct Object *bmeshobj, 
                                                                class BL_SkinMeshObject *mesh,
                                                                BL_ArmatureObject* arma)
                                                        :       //
-                                                       BL_MeshDeformer(bmeshobj, mesh),
+                                                       BL_MeshDeformer(gameobj, bmeshobj, mesh),
                                                        m_armobj(arma),
                                                        m_lastArmaUpdate(-1),
                                                        m_defbase(&bmeshobj->defbase),
@@ -71,12 +72,13 @@ BL_SkinDeformer::BL_SkinDeformer(struct Object *bmeshobj,
 };
 
 BL_SkinDeformer::BL_SkinDeformer(
+       BL_DeformableGameObject *gameobj,
        struct Object *bmeshobj_old,    // Blender object that owns the new mesh
        struct Object *bmeshobj_new,    // Blender object that owns the original mesh
        class BL_SkinMeshObject *mesh,
        bool release_object,
        BL_ArmatureObject* arma)        :       
-               BL_MeshDeformer(bmeshobj_old, mesh),
+               BL_MeshDeformer(gameobj, bmeshobj_old, mesh),
                m_armobj(arma),
                m_lastArmaUpdate(-1),
                m_defbase(&bmeshobj_old->defbase),
@@ -96,35 +98,32 @@ BL_SkinDeformer::~BL_SkinDeformer()
                m_armobj->Release();
 }
 
-bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
+bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *)
 {
-       size_t                  i, j, index;
-       vecVertexArray  array;
-       vecIndexArrays  mvarray;
-       vecMDVertArray  dvarray;
-       vecIndexArrays  diarray;
-
-       RAS_TexVert *tv;
-       MT_Point3 pt;
-//     float co[3];
-
-       Update();
-
-       array = m_pMeshObject->GetVertexCache(mat);
-       mvarray = m_pMeshObject->GetMVertCache(mat);
-       diarray = m_pMeshObject->GetDIndexCache(mat);
-       // For each array
-       for (i=0; i<array.size(); i++) {
-               //      For each vertex
-               for (j=0; j<array[i]->size(); j++) {
-
-                       tv = &((*array[i])[j]);
-                       
-                       index = ((*diarray[i])[j]);
-                       
-                       //      Copy the untransformed data from the original mvert
-                       //      Set the data
-                       tv->SetXYZ(m_transverts[((*mvarray[i])[index])]);
+       size_t i, j;
+
+       if (!Update())
+               // no need to update the cache
+               return false;
+
+       // Update all materials at once, so we can do the above update test
+       // without ending up with some materials not updated
+       for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial();
+               mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
+               RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial();
+
+               vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat);
+
+               // For each array
+               for (i=0; i<vertexarrays.size(); i++) {
+                       KX_VertexArray& vertexarray = (*vertexarrays[i]);
+
+                       // For each vertex
+                       // copy the untransformed data from the original mvert
+                       for (j=0; j<vertexarray.size(); j++) {
+                               RAS_TexVert& v = vertexarray[j];
+                               v.SetXYZ(m_transverts[v.getOrigIndex()]);
+                       }
                }
        }
 
index c5568c049cbda6535989f1e29b40ce63bf56e6a2..f35db8273c474f38c71d7d4901919bb27128065e 100644 (file)
@@ -63,12 +63,14 @@ public:
        }
        void SetArmature (class BL_ArmatureObject *armobj);
 
-       BL_SkinDeformer(struct Object *bmeshobj, 
+       BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+                                       struct Object *bmeshobj, 
                                        class BL_SkinMeshObject *mesh,
                                        BL_ArmatureObject* arma = NULL);
 
        /* this second constructor is needed for making a mesh deformable on the fly. */
-       BL_SkinDeformer(struct Object *bmeshobj_old,
+       BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+                                       struct Object *bmeshobj_old,
                                        struct Object *bmeshobj_new,
                                        class BL_SkinMeshObject *mesh,
                                        bool release_object,
index 49492923c7c07e5bb3bfdc44908a2d92b8c869c9..fa215df1e1c05d0ecf3a1bc153f91bf59d5c5adb 100644 (file)
 #include "KX_GameObject.h"
 #include "RAS_BucketManager.h"
 
-void BL_SkinMeshObject::AddPolygon(RAS_Polygon* poly)
-{
-       /* We're overriding this so that we can eventually associate faces with verts somehow */
-
-       //      For vertIndex in poly:
-       //              find the appropriate normal
-
-       RAS_MeshObject::AddPolygon(poly);
-}
-
-int BL_SkinMeshObject::FindOrAddDeform(unsigned int vtxarray, unsigned int mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat)
-{
-       BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-       int numvert = ao->m_MvertArrayCache1[vtxarray]->size();
-
-       /* Check to see if this has already been pushed */
-       for (vector<BL_MDVertMap>::iterator it = m_mvert_to_dvert_mapping[mv].begin();
-            it != m_mvert_to_dvert_mapping[mv].end();
-            it++)
-       {
-               if(it->mat == mat)
-                       return it->index;
-       }
-
-       ao->m_MvertArrayCache1[vtxarray]->push_back(mv);
-       ao->m_DvertArrayCache1[vtxarray]->push_back(dv);
-
-       BL_MDVertMap mdmap;
-       mdmap.mat = mat;
-       mdmap.index = numvert;
-       m_mvert_to_dvert_mapping[mv].push_back(mdmap);
-       
-       return numvert;
-};
-
-int    BL_SkinMeshObject::FindVertexArray(int numverts,RAS_IPolyMaterial* polymat)
-{
-       int array=-1;
-       
-       BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(polymat);
-
-
-       for (size_t i=0;i<ao->m_VertexArrayCache1.size();i++)
-       {
-               if ( (ao->m_TriangleArrayCount[i] + (numverts-2)) < BUCKET_MAX_TRIANGLES) 
-               {
-                        if((ao->m_VertexArrayCache1[i]->size()+numverts < BUCKET_MAX_INDICES))
-                               {
-                                       array = i;
-                                       ao->m_TriangleArrayCount[array]+=numverts-2;
-                                       break;
-                               }
-               }
-       }
-       
-
-       if (array == -1)
-       {
-               array = ao->m_VertexArrayCache1.size();
-               
-               vector<RAS_TexVert>* va = new vector<RAS_TexVert>;
-               ao->m_VertexArrayCache1.push_back(va);
-               
-               KX_IndexArray *ia = new KX_IndexArray();
-               ao->m_IndexArrayCache1.push_back(ia);
-
-               KX_IndexArray *bva = new KX_IndexArray();
-               ao->m_MvertArrayCache1.push_back(bva);
-
-               BL_DeformVertArray *dva = new BL_DeformVertArray();
-               ao->m_DvertArrayCache1.push_back(dva);
-
-               KX_IndexArray *da = new KX_IndexArray();
-               ao->m_DIndexArrayCache1.push_back(da);
-
-               ao->m_TriangleArrayCount.push_back(numverts-2);
-
-       }
-
-               
-       return array;
-}
-
-
 //void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,RAS_BucketManager* bucketmgr)
 void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec)
 {
index cc2b8de600e8952f0b674883a1ed4d99f8618430..c21fb64204bb2720dc0bb983f5daabf8a011b814 100644 (file)
 #include "DNA_key_types.h"
 #include "DNA_meshdata_types.h"
 
-typedef vector<struct MVert*> BL_MVertArray;
-typedef vector<struct MDeformVert*> BL_DeformVertArray;
-typedef vector<class BL_TexVert> BL_VertexArray;
-
-
-typedef vector<vector<struct MDeformVert*>*> vecMDVertArray;
-typedef vector<vector<class BL_TexVert>*> vecBVertexArray;
-
-class BL_SkinArrayOptimizer : public KX_ArrayOptimizer  
-{
-public:
-       BL_SkinArrayOptimizer(int index)
-               :KX_ArrayOptimizer (index) {};
-       virtual ~BL_SkinArrayOptimizer(){
-
-               for (vector<KX_IndexArray*>::iterator itv = m_MvertArrayCache1.begin();
-               !(itv == m_MvertArrayCache1.end());itv++)
-               {
-                       delete (*itv);
-               }
-               for (vector<BL_DeformVertArray*>::iterator itd = m_DvertArrayCache1.begin();
-               !(itd == m_DvertArrayCache1.end());itd++)
-               {
-                       delete (*itd);
-               }
-               for (vector<KX_IndexArray*>::iterator iti = m_DIndexArrayCache1.begin();
-               !(iti == m_DIndexArrayCache1.end());iti++)
-               {
-                       delete (*iti);
-               }
-               
-               m_MvertArrayCache1.clear();
-               m_DvertArrayCache1.clear();
-               m_DIndexArrayCache1.clear();
-       };
-
-       vector<KX_IndexArray*>          m_MvertArrayCache1;
-       vector<BL_DeformVertArray*>     m_DvertArrayCache1;
-       vector<KX_IndexArray*>          m_DIndexArrayCache1;
-
-};
-
 class BL_SkinMeshObject : public RAS_MeshObject
 {
 
 //     enum    {       BUCKET_MAX_INDICES = 16384};//2048};//8192};
 //     enum    {       BUCKET_MAX_TRIANGLES = 4096};
 
-       KX_ArrayOptimizer*              GetArrayOptimizer(RAS_IPolyMaterial* polymat)
-       {
-               KX_ArrayOptimizer** aop = (m_matVertexArrayS[*polymat]);
-               if (aop)
-                       return *aop;
-               int numelements = m_matVertexArrayS.size();
-               m_sortedMaterials.push_back(polymat);
-               
-               BL_SkinArrayOptimizer* ao = new BL_SkinArrayOptimizer(numelements);
-               m_matVertexArrayS.insert(*polymat,ao);
-               return ao;
-       }
-
 protected:
        vector<int>                              m_cacheWeightIndex;
 
 public:
-       struct BL_MDVertMap { RAS_IPolyMaterial *mat; int index; };
-       vector<vector<BL_MDVertMap> >   m_mvert_to_dvert_mapping;
-
        void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec);
 //     void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr);
 
-       int FindVertexArray(int numverts,RAS_IPolyMaterial* polymat);
        BL_SkinMeshObject(Mesh* mesh, int lightlayer) : RAS_MeshObject (mesh, lightlayer)
        { 
                m_class = 1;
@@ -144,42 +85,7 @@ public:
                        }
                }
        };
-
-       const vecIndexArrays& GetDIndexCache (RAS_IPolyMaterial* mat)
-       {
-               BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-               return ao->m_DIndexArrayCache1;
-       }
-       const vecMDVertArray&   GetDVertCache (RAS_IPolyMaterial* mat)
-       {
-               BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-               return ao->m_DvertArrayCache1;
-       }
-       const vecIndexArrays&   GetMVertCache (RAS_IPolyMaterial* mat)
-       {
-               BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-               return ao->m_MvertArrayCache1;
-       }
        
-       void AddPolygon(RAS_Polygon* poly);
-       int FindOrAddDeform(unsigned int vtxarray, unsigned int mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat);
-       int FindOrAddVertex(int vtxarray,const MT_Point3& xyz,
-               const MT_Point2& uv,
-               const MT_Point2& uv2,
-               const MT_Vector4& tangent,
-               const unsigned int rgbacolor,
-               const MT_Vector3& normal, int defnr, bool flat, RAS_IPolyMaterial* mat, int origindex)
-       {
-               BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);
-               int numverts = ao->m_VertexArrayCache1[vtxarray]->size();
-               int index = RAS_MeshObject::FindOrAddVertex(vtxarray, xyz, uv, uv2, tangent, rgbacolor, normal, flat, mat, origindex);
-
-               /* this means a new vertex was added, so we add the defnr too */
-               if(index == numverts)
-                       ao->m_DIndexArrayCache1[vtxarray]->push_back(defnr);
-
-               return index;
-       }
        // for shape keys, 
        void CheckWeightCache(struct Object* obj);
 
index 6e05ea31fe81a2ec86c6f5eef1b7a5213b3f83ea..1f87e9d9ac74db88783acfb088f6c032d0032bb7 100644 (file)
@@ -193,6 +193,7 @@ void BL_ConvertActuators(char* maggiename,
                                                actact->type, // + 1, because Blender starts to count at zero,
                                                actact->blendin,
                                                actact->priority,
+                                               actact->end_reset,
                                                actact->stridelength
                                                // Ketsji at 1, because zero is reserved for "NoDef"
                                                );
@@ -233,7 +234,8 @@ void BL_ConvertActuators(char* maggiename,
                                STR_String propname = ( ipoact->name ? ipoact->name : "");
                                // first bit?
                                bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE);
-                               bool force_local = (ipoact->flag & ACT_IPOFORCE_LOCAL);
+                               bool local = (ipoact->flag & ACT_IPOLOCAL);
+                               bool ipo_add = (ipoact->flag & ACT_IPOADD);
                                
                                KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
                                        gameobj,
@@ -244,8 +246,8 @@ void BL_ConvertActuators(char* maggiename,
                                        ipoact->type + 1, // + 1, because Blender starts to count at zero,
                                        // Ketsji at 1, because zero is reserved for "NoDef"
                                        ipo_as_force,
-                                       force_local
-                                       );
+                                       ipo_add,
+                                       local);
                                baseact = tmpbaseact;
                                break;
                        }
index 04cc119efee65625e1d3775d657a23cdccfd690d..2bcb604dd23b7a1853b9cd31c3dde4dacb7dfb53 100644 (file)
@@ -76,18 +76,36 @@ static inline void Py_Fatal(char *M) {
   virtual PyTypeObject *GetType(void) {return &Type;}; \
   virtual PyParentObject *GetParents(void) {return Parents;}
 
+
                                                                // This defines the _getattr_up macro
                                                                // which allows attribute and method calls
                                                                // to be properly passed up the hierarchy.
 #define _getattr_up(Parent) \
-  PyObject *rvalue = Py_FindMethod(Methods, this, const_cast<char*>(attr.ReadPtr())); \
-  if (rvalue == NULL) \
-    { \
+  PyObject *rvalue = NULL; \
+  if (attr=="__methods__") { \
+    PyObject *_attr_string = NULL; \
+    PyMethodDef *meth = Methods; \
+    rvalue = Parent::_getattr(attr); \
+    if (rvalue==NULL) { \
+       PyErr_Clear(); \
+       rvalue = PyList_New(0); \
+    } \
+    if (meth) { \
+      for (; meth->ml_name != NULL; meth++) { \
+        _attr_string = PyString_FromString(meth->ml_name); \
+               PyList_Append(rvalue, _attr_string); \
+               Py_DECREF(_attr_string); \
+         } \
+       } \
+  } else { \
+    rvalue = Py_FindMethod(Methods, this, const_cast<char*>(attr.ReadPtr())); \
+    if (rvalue == NULL) { \
       PyErr_Clear(); \
-      return Parent::_getattr(attr); \
+      rvalue = Parent::_getattr(attr); \
     } \
-  else \
-    return rvalue 
+  } \
+  return rvalue; \
+
 
 /**
  * These macros are helpfull when embedding Python routines. The second
index 9645bfbed4a55c0e00172024aa32c1bc4f7b1608..e1c8ef87dd17e38e6b58d2cffb3d766f14e9464c 100644 (file)
@@ -111,7 +111,7 @@ void SCA_ActuatorSensor::Update()
 {
        if (m_actuator)
        {
-               m_midresult = m_actuator->IsActive();
+               m_midresult = m_actuator->IsActive() && !m_actuator->IsNegativeEvent();
        }
 }
 
index 774b27c5ad46508115dfae5fc6a2529105d9747a..7ffb21b5490f86116bb2d27d7334898fe30b9323 100644 (file)
@@ -87,6 +87,7 @@ public:
        bool IsNegativeEvent() const;
        virtual ~SCA_IActuator();
 
+       void ClrLink() { m_links=0; }
        void IncLink() { m_links++; }
        void DecLink();
        bool IsNoLink() const { return !m_links; }
index 27e7d5faadab05f8bebcb73e3246379862b3e754..c5bb4a41552812c29389c529ffab80a9ffda3189 100644 (file)
@@ -40,7 +40,7 @@
 
 MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0);
 
-SCA_IObject::SCA_IObject(PyTypeObject* T): m_state(0), CValue(T)
+SCA_IObject::SCA_IObject(PyTypeObject* T): m_initState(0), m_state(0), CValue(T)
 {
        m_suspended = false;
 }
@@ -164,7 +164,9 @@ void SCA_IObject::ReParentLogic()
        {
                SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica();
                newactuator->ReParent(this);
+               // actuators are initially not connected to any controller
                newactuator->SetActive(false);
+               newactuator->ClrLink();
                oldactuators[act++] = newactuator;
        }
 
@@ -175,6 +177,7 @@ void SCA_IObject::ReParentLogic()
        {
                SCA_IController* newcontroller = (SCA_IController*)(*itc)->GetReplica();
                newcontroller->ReParent(this);
+               newcontroller->SetActive(false);
                oldcontrollers[con++]=newcontroller;
 
        }
@@ -186,6 +189,9 @@ void SCA_IObject::ReParentLogic()
        {
                SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica();
                newsensor->ReParent(this);
+               newsensor->SetActive(false);
+               // sensors are initially not connected to any controller
+               newsensor->ClrLink();
                oldsensors[sen++] = newsensor;
        }
 
index 07b4310a91edbce24c10cee0fcb48b763a3d59cd..38a7ed29dca91be24e8bee06ac0b5799c0a436f0 100644 (file)
@@ -68,6 +68,11 @@ protected:
         */
        bool m_suspended;
 
+       /**
+        * init state of object (used when object is created)
+        */
+       unsigned int                    m_initState;
+
        /**
         * current state = bit mask of state that are active
         */
@@ -117,6 +122,16 @@ public:
         */
        void Resume(void);
 
+       /**
+        * Set init state
+        */
+       void SetInitState(unsigned int initState) { m_initState = initState; }
+
+       /**
+        * initialize the state when object is created
+        */
+       void ResetState(void) { SetState(m_initState); }
+
        /**
         * Set the object state
         */
index f2ed6a803c2a145d5fcb2a5771d0da7ad62dd729..4ce49e7150716d87884fd2a885e5961e2770c8fc 100644 (file)
@@ -126,6 +126,8 @@ public:
        /** Resume sensing. */
        void Resume();
 
+       void ClrLink()
+               { m_links = 0; }
        void IncLink()
                { m_links++; }
        void DecLink();
index 06e012123b1b20cfe4d1b466024a1f935d3f186c..dd45d522b9ffee3e0c65ceca3e4b959ea00e2f37 100644 (file)
@@ -1,9 +1,11 @@
 
 #include "DNA_customdata_types.h"
+#include "DNA_material_types.h"
 
 #include "BL_BlenderShader.h"
+#include "BL_Material.h"
 
-#if 0
+#ifdef BLENDER_GLSL
 #include "GPU_extensions.h"
 #include "GPU_material.h"
 #endif
 
 const bool BL_BlenderShader::Ok()const
 {
-#if 0
+#ifdef BLENDER_GLSL
        return (mGPUMat != 0);
+#else
+       return 0;
 #endif
-
-       return false;
 }
 
-BL_BlenderShader::BL_BlenderShader(struct Material *ma)
+BL_BlenderShader::BL_BlenderShader(struct Material *ma, int lightlayer)
 :
-#if 0
+#ifdef BLENDER_GLSL
        mGPUMat(0),
 #endif
-       mBound(false)
+       mBound(false),
+       mLightLayer(lightlayer)
 {
-#if 0
-       if(ma)
-               mGPUMat = GPU_material_from_blender(ma, GPU_PROFILE_DERIVEDMESH);
+#ifdef BLENDER_GLSL
+       if(ma) {
+               GPU_material_from_blender(ma);
+               mGPUMat = ma->gpumaterial;
+       }
 #endif
 }
 
 BL_BlenderShader::~BL_BlenderShader()
 {
-#if 0
+#ifdef BLENDER_GLSL
        if(mGPUMat) {
                GPU_material_unbind(mGPUMat);
                mGPUMat = 0;
@@ -43,16 +48,12 @@ BL_BlenderShader::~BL_BlenderShader()
 #endif
 }
 
-void BL_BlenderShader::ApplyShader()
-{
-}
-
 void BL_BlenderShader::SetProg(bool enable)
 {
-#if 0
+#ifdef BLENDER_GLSL
        if(mGPUMat) {
                if(enable) {
-                       GPU_material_bind(mGPUMat);
+                       GPU_material_bind(mGPUMat, mLightLayer);
                        mBound = true;
                }
                else {
@@ -65,7 +66,7 @@ void BL_BlenderShader::SetProg(bool enable)
 
 int BL_BlenderShader::GetAttribNum()
 {
-#if 0
+#ifdef BLENDER_GLSL
        GPUVertexAttribs attribs;
        int i, enabled = 0;
 
@@ -82,17 +83,19 @@ int BL_BlenderShader::GetAttribNum()
                enabled = BL_MAX_ATTRIB;
 
        return enabled;
-#endif
-
+#else
        return 0;
+#endif
 }
 
-void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras)
+void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat)
 {
-#if 0
+#ifdef BLENDER_GLSL
        GPUVertexAttribs attribs;
        int i, attrib_num;
 
+       ras->SetAttribNum(0);
+
        if(!mGPUMat)
                return;
 
@@ -109,14 +112,24 @@ void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras)
                        if(attribs.layer[i].glindex > attrib_num)
                                continue;
 
-                       if(attribs.layer[i].type == CD_MTFACE)
-                               ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex);
+                       if(attribs.layer[i].type == CD_MTFACE) {
+                               if(!mat->uvName.IsEmpty() && strcmp(mat->uvName.ReadPtr(), attribs.layer[i].name) == 0)
+                                       ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex);
+                               else if(!mat->uv2Name.IsEmpty() && strcmp(mat->uv2Name.ReadPtr(), attribs.layer[i].name) == 0)
+                                       ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV2, attribs.layer[i].glindex);
+                               else
+                                       ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex);
+                       }
                        else if(attribs.layer[i].type == CD_TANGENT)
                                ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, attribs.layer[i].glindex);
                        else if(attribs.layer[i].type == CD_ORCO)
                                ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_ORCO, attribs.layer[i].glindex);
                        else if(attribs.layer[i].type == CD_NORMAL)
                                ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_NORM, attribs.layer[i].glindex);
+                       else if(attribs.layer[i].type == CD_MCOL)
+                               ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_VCOL, attribs.layer[i].glindex);
+                       else
+                               ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, attribs.layer[i].glindex);
                }
 
                ras->EnableTextures(true);
@@ -128,8 +141,8 @@ void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras)
 
 void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty )
 {
-#if 0
-       float obmat[4][4], viewmat[4][4];
+#ifdef BLENDER_GLSL
+       float obmat[4][4], viewmat[4][4], viewinvmat[4][4];
 
        if(!mGPUMat || !mBound)
                return;
@@ -142,7 +155,20 @@ void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty )
        model.getValue((float*)obmat);
        view.getValue((float*)viewmat);
 
-       GPU_material_bind_uniforms(mGPUMat, obmat, viewmat);
+       view.invert();
+       view.getValue((float*)viewinvmat);
+
+       GPU_material_bind_uniforms(mGPUMat, obmat, viewmat, viewinvmat);
+#endif
+}
+
+bool BL_BlenderShader::Equals(BL_BlenderShader *blshader)
+{
+#ifdef BLENDER_GLSL
+       /* to avoid unneeded state switches */
+       return (blshader && mGPUMat == blshader->mGPUMat && mLightLayer == blshader->mLightLayer);
+#else
+       return true;
 #endif
 }
 
index 4cab0e644c36441ad63d36aa1b5aa725073c5f39..b758d1a9cba313e0c75be0916ad75726e0f601f4 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef __BL_GPUSHADER_H__
 #define __BL_GPUSHADER_H__
 
-#if 0
+#ifdef BLENDER_GLSL
 #include "GPU_material.h"
 #endif
 
 #include "MT_Tuple3.h"
 #include "MT_Tuple4.h"
 
+#include "RAS_IPolygonMaterial.h"
+
 struct Material;
+class BL_Material;
 
 #define BL_MAX_ATTRIB  16
 
@@ -23,22 +26,24 @@ struct Material;
 class BL_BlenderShader
 {
 private:
-#if 0
+#ifdef BLENDER_GLSL
        GPUMaterial             *mGPUMat;
 #endif
        bool                    mBound;
+       int                             mLightLayer;
 
 public:
-       BL_BlenderShader(struct Material *ma);
+       BL_BlenderShader(struct Material *ma, int lightlayer);
        virtual ~BL_BlenderShader();
 
        const bool                      Ok()const;
        void                            SetProg(bool enable);
 
-       void ApplyShader();
-       void SetTexCoords(class RAS_IRasterizer* ras);
        int GetAttribNum();
+       void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat);
        void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty);
+
+       bool Equals(BL_BlenderShader *blshader);
 };
 
 #endif//__BL_GPUSHADER_H__
index f5312ccd02349d567185c5a9a333e649a09df9bb..7e3d6984f19dcf7723ab9f145c2ec12da9250312 100644 (file)
@@ -105,7 +105,8 @@ void BL_Material::GetConversionRGB(unsigned int *nrgb) {
        *nrgb   = rgb[3];
 }
 
-void BL_Material::SetConversionUV(MT_Point2 *nuv) {
+void BL_Material::SetConversionUV(const STR_String& name, MT_Point2 *nuv) {
+       uvName = name;
        uv[0] = *nuv++;
        uv[1] = *nuv++;
        uv[2] = *nuv++;
@@ -118,7 +119,8 @@ void BL_Material::GetConversionUV(MT_Point2 *nuv){
        *nuv++ = uv[2];
        *nuv   = uv[3];
 }
-void BL_Material::SetConversionUV2(MT_Point2 *nuv) {
+void BL_Material::SetConversionUV2(const STR_String& name, MT_Point2 *nuv) {
+       uv2Name = name;
        uv2[0] = *nuv++;
        uv2[1] = *nuv++;
        uv2[2] = *nuv++;
index ddb6662830abf2af2fae94ececf0e1919d7c12d2..568f7e171de0d88d47ea98d99c626ae842504c9a 100644 (file)
@@ -83,13 +83,16 @@ public:
        MT_Point2 uv[4];
        MT_Point2 uv2[4];
 
+       STR_String uvName;
+       STR_String uv2Name;
+
        void SetConversionRGB(unsigned int *rgb);
        void GetConversionRGB(unsigned int *rgb);
 
-       void SetConversionUV(MT_Point2 *uv);
+       void SetConversionUV(const STR_String& name, MT_Point2 *uv);
        void GetConversionUV(MT_Point2 *uv);
 
-       void SetConversionUV2(MT_Point2 *uv);
+       void SetConversionUV2(const STR_String& name, MT_Point2 *uv);
        void GetConversionUV2(MT_Point2 *uv);
 
        void SetSharedMaterial(bool v);
index 02b1ffd432a9dfc8c4efd7e4bc0d0899c5ca2a6c..0f445a9f32e97d044fc93ca519ba26949f45470e 100644 (file)
@@ -38,6 +38,8 @@ extern "C" {
 // ------------------------------------
 #define spit(x) std::cout << x << std::endl;
 
+BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL;
+
 //static PyObject *gTextureDict = 0;
 
 KX_BlenderMaterial::KX_BlenderMaterial(
@@ -126,32 +128,31 @@ void KX_BlenderMaterial::OnConstruction()
                // when material are reused between objects
                return;
        
-       if(mMaterial->glslmat) {
+       if(mMaterial->glslmat)
                SetBlenderGLSLShader();
-       }
-       else {
-               // for each unique material...
-               int i;
-               for(i=0; i<mMaterial->num_enabled; i++) {
-                       if( mMaterial->mapping[i].mapping & USEENV ) {
-                               if(!GLEW_ARB_texture_cube_map) {
-                                       spit("CubeMap textures not supported");
-                                       continue;
-                               }
-                               if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) )
+
+       // for each unique material...
+       int i;
+       for(i=0; i<mMaterial->num_enabled; i++) {
+               if( mMaterial->mapping[i].mapping & USEENV ) {
+                       if(!GLEW_ARB_texture_cube_map) {
+                               spit("CubeMap textures not supported");
+                               continue;
+                       }
+                       if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) )
+                               spit("unable to initialize image("<<i<<") in "<< 
+                                                mMaterial->matname<< ", image will not be available");
+               } 
+       
+               else {
+                       if( mMaterial->img[i] ) {
+                               if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
                                        spit("unable to initialize image("<<i<<") in "<< 
-                                                        mMaterial->matname<< ", image will not be available");
-                       } 
-               
-                       else {
-                               if( mMaterial->img[i] ) {
-                                       if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
-                                               spit("unable to initialize image("<<i<<") in "<< 
-                                                       mMaterial->matname<< ", image will not be available");
-                               }
+                                               mMaterial->matname<< ", image will not be available");
                        }
                }
        }
+
        mBlendFunc[0] =0;
        mBlendFunc[1] =0;
        mConstructed = true;
@@ -168,7 +169,11 @@ void KX_BlenderMaterial::OnExit()
        }
 
        if( mBlenderShader ) {
-               mBlenderShader->SetProg(false);
+               if(mBlenderShader == mLastBlenderShader) {
+                       mBlenderShader->SetProg(false);
+                       mLastBlenderShader = NULL;
+               }
+
                delete mBlenderShader;
                mBlenderShader = 0;
        }
@@ -225,14 +230,23 @@ void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras
 {
        if( !enable || !mBlenderShader->Ok() ) {
                // frame cleanup.
-               mBlenderShader->SetProg(false);
+               if(mLastBlenderShader) {
+                       mLastBlenderShader->SetProg(false);
+                       mLastBlenderShader= NULL;
+               }
                BL_Texture::DisableAllTextures();
                return;
        }
 
-       BL_Texture::DisableAllTextures();
-       mBlenderShader->SetProg(true);
-       mBlenderShader->ApplyShader();
+       if(!mBlenderShader->Equals(mLastBlenderShader)) {
+               BL_Texture::DisableAllTextures();
+
+               if(mLastBlenderShader)
+                       mLastBlenderShader->SetProg(false);
+
+               mBlenderShader->SetProg(true);
+               mLastBlenderShader= mBlenderShader;
+       }
 }
 
 void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras)
@@ -298,7 +312,12 @@ KX_BlenderMaterial::ActivatShaders(
        // reset... 
        if(tmp->mMaterial->IsShared()) 
                cachingInfo =0;
-       
+
+       if(mLastBlenderShader) {
+               mLastBlenderShader->SetProg(false);
+               mLastBlenderShader= NULL;
+       }
+
        if (GetCachingInfo() != cachingInfo) {
 
                if (!cachingInfo)
@@ -372,7 +391,7 @@ KX_BlenderMaterial::ActivateBlenderShaders(
        }
 
        ActivatGLMaterials(rasty);
-       mBlenderShader->SetTexCoords(rasty);
+       mBlenderShader->SetAttribs(rasty, mMaterial);
 }
 
 void
@@ -382,6 +401,12 @@ KX_BlenderMaterial::ActivateMat(
        )const
 {
        KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
+
+       if(mLastBlenderShader) {
+               mLastBlenderShader->SetProg(false);
+               mLastBlenderShader= NULL;
+       }
+
        if (GetCachingInfo() != cachingInfo) {
                if (!cachingInfo) 
                        tmp->setTexData( false,rasty );
@@ -460,17 +485,29 @@ KX_BlenderMaterial::Activate(
        return dopass;
 }
 
+bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const
+{
+       if(!RAS_IPolyMaterial::UsesLighting(rasty))
+               return false;
+
+       if(mShader && mShader->Ok());
+       else if(mBlenderShader && mBlenderShader->Ok())
+               return false;
+       
+       return true;
+}
+
 void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const
 {
        if(mShader && GLEW_ARB_shader_objects)
                mShader->Update(ms, rasty);
-       if(mBlenderShader && GLEW_ARB_shader_objects)
+       else if(mBlenderShader && GLEW_ARB_shader_objects)
                mBlenderShader->Update(ms, rasty);
 }
 
 void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const
 {
-       if(!mBlenderShader) {
+       if(mShader || !mBlenderShader) {
                rasty->SetSpecularity(
                        mMaterial->speccolor[0]*mMaterial->spec_f,
                        mMaterial->speccolor[1]*mMaterial->spec_f,
@@ -506,6 +543,7 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const
                ras->SetAttribNum(0);
                if(mShader && GLEW_ARB_shader_objects) {
                        if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT) {
+                               ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, 0);
                                ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, 1);
                                ras->SetAttribNum(2);
                        }
@@ -793,7 +831,7 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
 void KX_BlenderMaterial::SetBlenderGLSLShader(void)
 {
        if(!mBlenderShader)
-               mBlenderShader = new BL_BlenderShader(mMaterial->material);
+               mBlenderShader = new BL_BlenderShader(mMaterial->material, m_lightlayer);
 
        if(!mBlenderShader->Ok()) {
                delete mBlenderShader;
index 62e96b71937e8d7c84b8157265668a561e2912c7..bf6d2095e7c9b4e35c9dce144860be562d3576ef 100644 (file)
@@ -94,6 +94,7 @@ private:
        BL_Material*            mMaterial;
        BL_Shader*                      mShader;
        BL_BlenderShader*       mBlenderShader;
+       static BL_BlenderShader *mLastBlenderShader;
        KX_Scene*               mScene;
        BL_Texture              mTextures[MAXTEX];              // texture array
        bool                    mUserDefBlend;
@@ -106,6 +107,7 @@ private:
        void ActivatGLMaterials( RAS_IRasterizer* rasty )const;
        void ActivateTexGen( RAS_IRasterizer *ras ) const;
 
+       bool UsesLighting(RAS_IRasterizer *rasty) const;
 
        // message centers
        void    setTexData( bool enable,RAS_IRasterizer *ras);
index bde5e2cd0a28f53ca15a3ff2058e3b4835778097..2ac4f909077e5eb9e9e4c7156910e098b40bbd94 100644 (file)
@@ -405,34 +405,25 @@ void KX_GameObject::ResetDebugColor()
        SetDebugColor(0xff000000);
 }
 
+void KX_GameObject::InitIPO(bool ipo_as_force,
+                                                       bool ipo_add,
+                                                       bool ipo_local)
+{
+       SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin();
 
+       while (it != GetSGNode()->GetSGControllerList().end()) {
+               (*it)->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true);
+               (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force);
+               (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, ipo_add);
+               (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, ipo_local);
+               it++;
+       }
+} 
 
 void KX_GameObject::UpdateIPO(float curframetime,
-                                                         bool recurse,
-                                                         bool ipo_as_force,
-                                                         bool force_local) 
+                                                         bool recurse) 
 {
-
-       // The ipo-actuator needs a sumo reference... this is retrieved (unfortunately)
-       // by the iposgcontr itself...
-//             ipocontr->SetSumoReference(gameobj->GetSumoScene(), 
-//                                                                gameobj->GetSumoObject());
-
-
-       // The ipo has to be treated as a force, and not a displacement!
-       // For this case, we send some settings to the controller. This
-       // may need some caching...
-       if (ipo_as_force) {
-               SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin();
-
-               while (it != GetSGNode()->GetSGControllerList().end()) {
-                       (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force);
-                       (*it)->SetOption(SG_Controller::SG_CONTR_IPO_FORCES_ACT_LOCAL, force_local);
-                       it++;
-               }
-       } 
-
-       // The rest is the 'normal' update procedure.
+       // just the 'normal' update procedure.
        GetSGNode()->SetSimulatedTime(curframetime,recurse);
        GetSGNode()->UpdateWorldData(curframetime);
        UpdateTransform();
@@ -581,7 +572,7 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec)
        m_objectColor = rgbavec;
 }
 
-void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis)
+void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
 {
        MT_Matrix3x3 orimat;
        MT_Vector3 vect,ori,z,x,y;
@@ -594,6 +585,11 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis)
                cout << "alignAxisToVect() Error: Null vector!\n";
                return;
        }
+       
+       if (fac<=0.0) {
+               return;
+       }
+       
        // normalize
        vect /= len;
        orimat = GetSGNode()->GetWorldOrientation();
@@ -603,7 +599,14 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis)
                        ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
                        if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot?
                                ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
-                       x = vect; 
+                       if (fac == 1.0) {
+                               x = vect;
+                       } else {
+                               x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1-fac));
+                               len = x.length();
+                               if (MT_fuzzyZero(len)) x = vect;
+                               else x /= len;
+                       }
                        y = ori.cross(x);
                        z = x.cross(y);
                        break;
@@ -611,7 +614,14 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis)
                        ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
                        if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
                                ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]);
-                       y = vect;
+                       if (fac == 1.0) {
+                               y = vect;
+                       } else {
+                               y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1-fac));
+                               len = y.length();
+                               if (MT_fuzzyZero(len)) y = vect;
+                               else y /= len;
+                       }
                        z = ori.cross(y);
                        x = y.cross(z);
                        break;
@@ -619,7 +629,14 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis)
                        ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]);
                        if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
                                ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
-                       z = vect;
+                       if (fac == 1.0) {
+                               z = vect;
+                       } else {
+                               z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1-fac));
+                               len = z.length();
+                               if (MT_fuzzyZero(len)) z = vect;
+                               else z /= len;
+                       }
                        x = ori.cross(z);
                        y = z.cross(x);
                        break;
@@ -1289,7 +1306,7 @@ PyObject* KX_GameObject::PyGetMesh(PyObject* self,
                        return meshproxy;
                }
        }
-       return NULL;
+       Py_RETURN_NONE;
 }
 
 
@@ -1395,13 +1412,14 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self,
 {
        PyObject* pyvect;
        int axis = 2; //z axis is the default
+       float fac = 1.0;
        
-       if (PyArg_ParseTuple(args,"O|i",&pyvect,&axis))
+       if (PyArg_ParseTuple(args,"O|if",&pyvect,&axis, &fac))
        {
                MT_Vector3 vect;
                if (PyVecTo(pyvect, vect))
                {
-                       AlignAxisToVect(vect,axis);                             
+                       AlignAxisToVect(vect,axis,fac);
                        Py_RETURN_NONE;
                }
        }
@@ -1590,14 +1608,18 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
                other = static_cast<KX_GameObject*>(pyfrom);
                fromPoint = other->NodeGetWorldPosition();
        }
-
-       if (dist != 0.0f)
-       {
+       
+       if (dist != 0.0f) {
                MT_Vector3 toDir = toPoint-fromPoint;
+               if (MT_fuzzyZero(toDir.length2())) {
+                       return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+               }
                toDir.normalize();
                toPoint = fromPoint + (dist) * toDir;
+       } else if (MT_fuzzyZero((toPoint-fromPoint).length2())) {
+               return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
        }
-
+       
        MT_Point3 resultPoint;
        MT_Vector3 resultNormal;
        PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment();
index 5e44a36515d92ad02ae9753af077ade4fca52939..ddbf863aa1afe960051178ad43f64bd2f3119380 100644 (file)
@@ -278,7 +278,8 @@ public:
                void 
        AlignAxisToVect(
                const MT_Vector3& vect,
-               int axis = 2 
+               int axis = 2,
+               float fac = 1.0
        );
 
        /** 
@@ -489,15 +490,23 @@ public:
        UpdateNonDynas(
        );
 
+       /**
+        * Function to set IPO option at start of IPO
+        */ 
+               void    
+       InitIPO(
+               bool ipo_as_force,
+               bool ipo_add,
+               bool ipo_local
+       );
+
        /**
         * Odd function to update an ipo. ???
         */ 
                void    
        UpdateIPO(
                float curframetime,
-               bool recurse, 
-               bool ipo_as_force,
-               bool force_ipo_local
+               bool recurse
        );
        /**
         * Updates Material Ipo data 
index 5303e9a9e85d86f61766fb3e046effa52fa4111c..d3aa924665e6531574a741623b3f7b2ff1c1c2bb 100644 (file)
@@ -55,7 +55,8 @@ typedef unsigned long uint_ptr;
 // start on another frame, the 1.0 should change.
 KX_IpoSGController::KX_IpoSGController() 
 : m_ipo_as_force(false),
-  m_force_ipo_acts_local(false),
+  m_ipo_add(false),
+  m_ipo_local(false),
   m_modified(true),
   m_ipo_start_initialized(false),
   m_ipotime(1.0)
@@ -75,8 +76,23 @@ void KX_IpoSGController::SetOption(
                m_ipo_as_force = (value != 0);
                m_modified = true;
                break;
-       case SG_CONTR_IPO_FORCES_ACT_LOCAL:
-               m_force_ipo_acts_local = (value != 0);
+       case SG_CONTR_IPO_IPO_ADD:
+               m_ipo_add = (value != 0);
+               m_modified = true;
+               break;
+       case SG_CONTR_IPO_RESET:
+               if (m_ipo_start_initialized && value) {
+                       m_ipo_start_initialized = false;
+                       m_modified = true;
+               }
+               break;
+       case SG_CONTR_IPO_LOCAL:
+               if (value/* && ((SG_Node*)m_pObject)->GetSGParent() == NULL*/) {
+                       // only accept local Ipo if the object has no parent
+                       m_ipo_local = true;
+               } else {
+                       m_ipo_local = false;
+               }
                m_modified = true;
                break;
        default:
@@ -129,15 +145,19 @@ bool KX_IpoSGController::Update(double currentTime)
                        {
                                if (m_game_object && ob) 
                                {
-                                       m_game_object->GetPhysicsController()->ApplyForce(m_force_ipo_acts_local ?
+                                       m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ?
                                                ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
                                                m_ipo_xform.GetPosition(), false);
                                }
                        } 
                        else
                        {
-                               //by default, leave object as it stands
-                               MT_Point3 newPosition = ob->GetLocalPosition();
+                               // Local ipo should be defined with the object position at (0,0,0)
+                               // Local transform is applied to the object based on initial position
+                               MT_Point3 newPosition(0.0,0.0,0.0);
+                               
+                               if (!m_ipo_add)
+                                       newPosition = ob->GetLocalPosition();
                                //apply separate IPO channels if there is any data in them
                                //Loc and dLoc act by themselves or are additive
                                //LocX and dLocX
@@ -145,23 +165,28 @@ bool KX_IpoSGController::Update(double currentTime)
                                        newPosition[0] = (m_ipo_channels_active[OB_DLOC_X] ? m_ipo_xform.GetPosition()[0] + m_ipo_xform.GetDeltaPosition()[0] : m_ipo_xform.GetPosition()[0]);
                                }
                                else if (m_ipo_channels_active[OB_DLOC_X] && m_ipo_start_initialized) {
-                                       newPosition[0] = (m_ipo_start_point[0] + m_ipo_xform.GetDeltaPosition()[0]);
+                                       newPosition[0] = (((!m_ipo_add)?m_ipo_start_point[0]:0.0) + m_ipo_xform.GetDeltaPosition()[0]);
                                }
                                //LocY and dLocY
                                if (m_ipo_channels_active[OB_LOC_Y]) {
                                        newPosition[1] = (m_ipo_channels_active[OB_DLOC_Y] ? m_ipo_xform.GetPosition()[1] + m_ipo_xform.GetDeltaPosition()[1] : m_ipo_xform.GetPosition()[1]);
                                }
                                else if (m_ipo_channels_active[OB_DLOC_Y] && m_ipo_start_initialized) {
-                                       newPosition[1] = (m_ipo_start_point[1] + m_ipo_xform.GetDeltaPosition()[1]);
+                                       newPosition[1] = (((!m_ipo_add)?m_ipo_start_point[1]:0.0) + m_ipo_xform.GetDeltaPosition()[1]);
                                }
                                //LocZ and dLocZ
                                if (m_ipo_channels_active[OB_LOC_Z]) {
                                        newPosition[2] = (m_ipo_channels_active[OB_DLOC_Z] ? m_ipo_xform.GetPosition()[2] + m_ipo_xform.GetDeltaPosition()[2] : m_ipo_xform.GetPosition()[2]);
                                }
                                else if (m_ipo_channels_active[OB_DLOC_Z] && m_ipo_start_initialized) {
-                                       newPosition[2] = (m_ipo_start_point[2] + m_ipo_xform.GetDeltaPosition()[2]);
+                                       newPosition[2] = (((!m_ipo_add)?m_ipo_start_point[2]:0.0) + m_ipo_xform.GetDeltaPosition()[2]);
+                               }
+                               if (m_ipo_add) {
+                                       if (m_ipo_local)
+                                               newPosition = m_ipo_start_point + m_ipo_start_scale*(m_ipo_start_orient*newPosition);
+                                       else
+                                               newPosition = m_ipo_start_point + newPosition;
                                }
-                               
                                ob->SetLocalPosition(newPosition);
                        }
                }
@@ -170,21 +195,23 @@ bool KX_IpoSGController::Update(double currentTime)
                        if (m_ipo_as_force) {
                                
                                if (m_game_object && ob) {
-                                       m_game_object->ApplyTorque(m_force_ipo_acts_local ?
+                                       m_game_object->ApplyTorque(m_ipo_local ?
                                                ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() :
                                                m_ipo_xform.GetEulerAngles(), false);
                                }
                        } else {
-                               double yaw, pitch,  roll;       //final Euler angles
+                               double yaw=0, pitch=0,  roll=0; //final Euler angles
                                double tempYaw=0, tempPitch=0, tempRoll=0;      //temp holders
-                               ob->GetLocalOrientation().getEuler(yaw, pitch, roll);
+                               if (!m_ipo_add)
+                                       ob->GetLocalOrientation().getEuler(yaw, pitch, roll);
 
                                //RotX and dRotX
                                if (m_ipo_channels_active[OB_ROT_X]) {
                                        yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] );
                                }
                                else if (m_ipo_channels_active[OB_DROT_X] && m_ipo_start_initialized) {
-                                       m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll);
+                                       if (!m_ipo_add)
+                                               m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll);
                                        yaw = tempYaw + m_ipo_xform.GetDeltaEulerAngles()[0];
                                }
 
@@ -193,7 +220,8 @@ bool KX_IpoSGController::Update(double currentTime)
                                        pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] );
                                }
                                else if (m_ipo_channels_active[OB_DROT_Y] && m_ipo_start_initialized) {
-                                       m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll);
+                                       if (!m_ipo_add)
+                                               m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll);
                                        pitch = tempPitch + m_ipo_xform.GetDeltaEulerAngles()[1];
                                }
                                
@@ -202,23 +230,34 @@ bool KX_IpoSGController::Update(double currentTime)
                                        roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] );
                                }
                                else if (m_ipo_channels_active[OB_DROT_Z] && m_ipo_start_initialized) {
-                                       m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll);
+                                       if (!m_ipo_add)
+                                               m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll);
                                        roll = tempRoll + m_ipo_xform.GetDeltaEulerAngles()[2];
                                }
-
-                               ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll));
+                               if (m_ipo_add) {
+                                       MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll));
+                                       if (m_ipo_local)
+                                               rotation = m_ipo_start_orient * rotation;
+                                       else
+                                               rotation = rotation * m_ipo_start_orient;
+                                       ob->SetLocalOrientation(rotation);
+                               } else {
+                                       ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll));
+                               }
                        }
                }
                //modifies scale?
                if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] || m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z]) {
                        //default is no scale change
-                       MT_Vector3 newScale = ob->GetLocalScale();
+                       MT_Vector3 newScale(1.0,1.0,1.0);
+                       if (!m_ipo_add)
+                               newScale = ob->GetLocalScale();
 
                        if (m_ipo_channels_active[OB_SIZE_X]) {
                                newScale[0] = (m_ipo_channels_active[OB_DSIZE_X] ? (m_ipo_xform.GetScaling()[0] + m_ipo_xform.GetDeltaScaling()[0]) : m_ipo_xform.GetScaling()[0]);
                        }
                        else if (m_ipo_channels_active[OB_DSIZE_X] && m_ipo_start_initialized) {
-                               newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + m_ipo_start_scale[0]);
+                               newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + ((!m_ipo_add)?m_ipo_start_scale[0]:0.0));
                        }
 
                        //RotY dRotY
@@ -226,7 +265,7 @@ bool KX_IpoSGController::Update(double currentTime)
                                newScale[1] = (m_ipo_channels_active[OB_DSIZE_Y] ? (m_ipo_xform.GetScaling()[1] + m_ipo_xform.GetDeltaScaling()[1]): m_ipo_xform.GetScaling()[1]);
                        }
                        else if (m_ipo_channels_active[OB_DSIZE_Y] && m_ipo_start_initialized) {
-                               newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + m_ipo_start_scale[1]);
+                               newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + ((!m_ipo_add)?m_ipo_start_scale[1]:0.0));
                        }
                        
                        //RotZ and dRotZ
@@ -234,7 +273,11 @@ bool KX_IpoSGController::Update(double currentTime)
                                newScale[2] = (m_ipo_channels_active[OB_DSIZE_Z] ? (m_ipo_xform.GetScaling()[2] + m_ipo_xform.GetDeltaScaling()[2]) : m_ipo_xform.GetScaling()[2]);
                        }
                        else if (m_ipo_channels_active[OB_DSIZE_Z] && m_ipo_start_initialized) {
-                               newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + m_ipo_start_scale[2]);
+                               newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + ((!m_ipo_add)?m_ipo_start_scale[2]:1.0));
+                       }
+
+                       if (m_ipo_add) {
+                               newScale = m_ipo_start_scale * newScale;
                        }
 
                        ob->SetLocalScale(newScale);
index 7b5a151b41ce5029c2186675da6ee9f833fdfda6..0bd8980f11c1bba4cb973f94c0c83600d9458321 100644 (file)
@@ -48,8 +48,11 @@ class KX_IpoSGController : public SG_Controller
        /** Interpret the ipo as a force rather than a displacement? */
        bool                m_ipo_as_force;
 
-       /** Ipo-as-force acts in local rather than in global coordinates? */
-       bool                m_force_ipo_acts_local;
+       /** Add Ipo curve to current loc/rot/scale */
+       bool                m_ipo_add;
+
+       /** Ipo must be applied in local coordinate rather than in global coordinates (used for force and Add mode)*/
+       bool                m_ipo_local;
        
        /** Were settings altered since the last update? */
        bool                            m_modified;
index cf246342cf93e720eccb98b4f61247790f35be1b..b7103f49aeef7bdf2c13adb0675672b15ed6a637 100644 (file)
@@ -59,40 +59,6 @@ STR_String KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp";
 /* ------------------------------------------------------------------------- */
 /* Native functions                                                          */
 /* ------------------------------------------------------------------------- */
-/** Another poltergeist? This seems to be a very transient class... */
-class CIpoAction : public CAction
-{
-       float           m_curtime;
-       bool            m_recurse;
-       KX_GameObject* m_gameobj;
-       bool        m_ipo_as_force;
-       bool        m_force_ipo_local;
-
-public:
-       CIpoAction(KX_GameObject* gameobj,
-               float curtime,
-               bool recurse, 
-               bool ipo_as_force,
-               bool force_ipo_local) :
-         m_curtime(curtime) ,
-         m_recurse(recurse),
-         m_gameobj(gameobj),
-         m_ipo_as_force(ipo_as_force),
-         m_force_ipo_local(force_ipo_local) 
-         {
-                 /* intentionally empty */
-         };
-
-       virtual void Execute() const
-       {
-               m_gameobj->UpdateIPO(
-                       m_curtime, 
-                       m_recurse, 
-                       m_ipo_as_force, 
-                       m_force_ipo_local);
-       };
-
-};
 
 KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
                                                           const STR_String& propname,
@@ -101,7 +67,8 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
                                                           bool recurse,
                                                           int acttype,
                                                           bool ipo_as_force,
-                                                          bool force_ipo_local,
+                                                          bool ipo_add,
+                                                          bool ipo_local,
                                                           PyTypeObject* T) 
        : SCA_IActuator(gameobj,T),
        m_bNegativeEvent(false),
@@ -112,7 +79,8 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
        m_direction(1),
        m_propname(propname),
        m_ipo_as_force(ipo_as_force),
-       m_force_ipo_local(force_ipo_local),
+       m_ipo_add(ipo_add),
+       m_ipo_local(ipo_local),
        m_type((IpoActType)acttype)
 {
        m_starttime = -2.0*fabs(m_endframe - m_startframe) - 1.0;
@@ -160,7 +128,7 @@ bool KX_IpoActuator::ClampLocalTime()
 
 void KX_IpoActuator::SetStartTime(float curtime)
 {
-       float direction = m_startframe < m_endframe ? 1.0 : -1.0;
+       float direction = m_startframe < m_endframe ? 1.0f : -1.0f;
 
        curtime = curtime - KX_KetsjiEngine::GetSuspendedDelta();       
        if (m_direction > 0)
@@ -195,31 +163,26 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
        // maybe there are events for us in the queue !
        bool bNegativeEvent = false;
        int numevents = 0;
+       bool bIpoStart = false;
 
        if (frame)
        {
                numevents = m_events.size();
-               for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
-               {
-                       --i;
-                       if ((*i)->GetNumber() == 0.0f)
-                               bNegativeEvent = true;
-                       
-                       (*i)->Release();
-               }
-               m_events.clear();
+               bNegativeEvent = IsNegativeEvent();
+               RemoveAllEvents();
        }
        
-       double  start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0);
+       float  start_smaller_then_end = ( m_startframe < m_endframe ? 1.0f : -1.0f);
 
        bool result=true;
        if (!bNegativeEvent)
        {
-               if (m_starttime < -2.0*start_smaller_then_end*(m_endframe - m_startframe))
+               if (m_starttime < -2.0f*start_smaller_then_end*(m_endframe - m_startframe))
                {
                        // start for all Ipo, initial start for LOOP_STOP
                        m_starttime = curtime - KX_KetsjiEngine::GetSuspendedDelta();
                        m_bIpoPlaying = true;
+                       bIpoStart = true;
                }
        }       
 
@@