Warning fixes for previous Image commit, also fixed verse_image.c
authorTon Roosendaal <ton@blender.org>
Wed, 20 Dec 2006 18:29:23 +0000 (18:29 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 20 Dec 2006 18:29:23 +0000 (18:29 +0000)
source/blender/render/intern/source/convertblender.c
source/blender/src/drawobject.c
source/blender/src/editconstraint.c
source/blender/src/verse_image.c
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/Ketsji/BL_Texture.cpp

index 4f7420bacc2ebf565033f2ddbcd4ddd7149231fa..650eba5fef07b1d7644bc0e0b00506c4aed31f93 100644 (file)
@@ -2005,7 +2005,7 @@ static void init_render_mesh(Render *re, Object *ob, Object *par, int only_verts
                        if(end && (ma->mode & MA_WIRE)) {
                                MEdge *medge;
                                struct edgesort *edgetable;
-                               int totedge;
+                               int totedge= 0;
                                
                                medge= dm->getEdgeArray(dm);
                                
index 552d2b5eeee2efedad268a865e9e8878078c5ef6..538e7e6fef230df6c81be3a2d841e6742becec26 100644 (file)
@@ -3640,7 +3640,6 @@ static void draw_hooks(Object *ob)
 //<rcruiz>
 void drawRBpivot(bRigidBodyJointConstraint *data){
        float radsPerDeg = 6.283185307179586232f / 360.f;
-       float size=1.0f;
        int axis;
        float v1[3]= {data->pivX, data->pivY, data->pivZ};
        float eu[3]= {radsPerDeg*data->axX, radsPerDeg*data->axY, radsPerDeg*data->axZ};
@@ -3654,7 +3653,7 @@ void drawRBpivot(bRigidBodyJointConstraint *data){
        for (axis=0; axis<3; axis++) {
                        float dir[3] = {0,0,0};
                        float v[3]= {data->pivX, data->pivY, data->pivZ};
-                       int arrow_axis= (axis==0)?1:0;
+
                        dir[axis] = 1.f;
                        glBegin(GL_LINES);
                        Mat4MulVecfl(mat,dir);
index ba0b43c16a8c05e1adea00c591392b9789d75954..bb921906d55bfe28541746a5ad9fb34eb5a34eb5 100644 (file)
@@ -831,7 +831,7 @@ void rename_constraint(Object *ob, bConstraint *con, char *oldname)
        bConstraintChannel *conchan;
        ListBase *conlist= NULL;
        int from_object= 0;
-       char *channame;
+       char *channame="";
        
        /* get context by searching for con (primitive...) */
        for(tcon= ob->constraints.first; tcon; tcon= tcon->next)
index 8a82f120a1d6388d38a44067220176e3ac5d4400..9e9b478980e892f7421d6caeed5bd4e9746e80c8 100644 (file)
@@ -32,6 +32,7 @@
 #include "mydevice.h"
 
 #include "BKE_verse.h"
+#include "BKE_image.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -60,6 +61,7 @@ void unsubscribe_from_bitmap_node(VNode *vnode)
  */
 void push_image_to_verse_server(VerseSession *session, Image *image)
 {
+       ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
        struct VNode *vnode;
 
        if(!session) return;
@@ -77,9 +79,9 @@ void push_image_to_verse_server(VerseSession *session, Image *image)
        strcat(vnode->name, image->id.name+2);
 
        /* set up dimension of image */
-       if(image->ibuf) {
-               ((VBitmapData*)vnode->data)->width = image->ibuf->x;
-               ((VBitmapData*)vnode->data)->height = image->ibuf->y;
+       if(ibuf) {
+               ((VBitmapData*)vnode->data)->width = ibuf->x;
+               ((VBitmapData*)vnode->data)->height = ibuf->y;
        }
        else {
                ((VBitmapData*)vnode->data)->width = 0;
@@ -101,13 +103,12 @@ void push_image_to_verse_server(VerseSession *session, Image *image)
 void sync_blender_image_channel_with_verse_layer(VNode *vnode, VBitmapLayer *vblayer)
 {
        struct Image *image = (Image*)((VBitmapData*)(vnode->data))->image;
-       struct ImBuf *ibuf;
+       struct ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
        unsigned char *rect;
        int x, y, height, t_width, i, channel=0;
 
        if(!image) return;
 
-       ibuf = image->ibuf;
        if(!ibuf) return;
 
        rect = (unsigned char*)ibuf->rect;
@@ -172,11 +173,10 @@ void sync_blender_image_with_verse_bitmap_node(VNode *vnode)
 void post_bitmap_dimension_set(VNode *vnode)
 {
        struct Image *image = (Image*)((VBitmapData*)(vnode->data))->image;
-       struct ImBuf *ibuf;
+       struct ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
 
        if(!image) return;
 
-       ibuf = image->ibuf;
        if(!ibuf) return;
 
        if(vnode->owner_id == VN_OWNER_MINE) {
@@ -200,9 +200,9 @@ void post_bitmap_dimension_set(VNode *vnode)
                new_ibuf= IMB_allocImBuf(((VBitmapData*)vnode->data)->width,
                                ((VBitmapData*)vnode->data)->height, 24, IB_rect, 0);
                /* free old ibuf */
-               IMB_freeImBuf(ibuf);
+               BKE_image_signal(image, NULL, IMA_SIGNAL_FREE);
                /* set up pointer at new ibuf */
-               image->ibuf = new_ibuf;
+               BKE_image_assign_ibuf(image, ibuf);
                
                /* sync blender image with all verse layers */
                vblayer = ((VBitmapData*)(vnode->data))->layers.lb.first;
@@ -222,7 +222,7 @@ void post_bitmap_layer_create(VBitmapLayer *vblayer)
 {
        struct VNode *vnode = vblayer->vnode;
        struct Image *image = (Image*)((VBitmapData*)(vnode->data))->image;
-       struct ImBuf *ibuf;
+       struct ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
        unsigned char *rect;
        short channel;
 /*     VNBTile tile[VN_B_TILE_SIZE*VN_B_TILE_SIZE];
@@ -234,7 +234,6 @@ void post_bitmap_layer_create(VBitmapLayer *vblayer)
        
        if(!image) return;
 
-       ibuf = image->ibuf;
        if(!ibuf) return;
 
        rect = (unsigned char*)ibuf->rect;
@@ -269,13 +268,12 @@ void post_bitmap_tile_set(VBitmapLayer *vblayer, unsigned int xs, unsigned int y
 {
        struct VNode *vnode = vblayer->vnode;
        struct Image *image = (Image*)((VBitmapData*)(vnode->data))->image;
-       struct ImBuf *ibuf;
+       struct ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
        unsigned char *rect, *i_rect;
        unsigned int x, y, t_width, t_height, height, m_ys, m_y, d, i, j, channel=0;
 
        if(!image) return;
 
-       ibuf = image->ibuf;
        if(!ibuf) return;
 
        /* select channel due to verse layer name */
index da3bda0a220f6980cd139213a8e81d9fd2f20939..8f7609aed74df754c13df79ec4dd55f2fd90a8ca 100644 (file)
@@ -74,6 +74,7 @@
 
 #include "BKE_global.h"
 #include "BKE_bmfont.h"
+#include "BKE_image.h"
 
 #include "BIF_gl.h"
 extern "C" {
@@ -141,7 +142,7 @@ void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface
                                // space starts at offset 1
                                // character = character - ' ' + 1;
                                
-                               matrixGlyph(ima->ibuf, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
+                               matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
 
                                glBegin(GL_POLYGON);
                                // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], );
index 68d2c3337a7508e091a59a6818d4d0e02f8e96b6..0867b41d9ae80064a7caf75e05459b7fbf1fdc79 100644 (file)
@@ -92,19 +92,19 @@ void BL_Texture::DeleteTex()
 
 bool BL_Texture::InitFromImage(int unit,  Image *img, bool mipmap)
 {
+       ImBuf *ibuf;
+       
        if(!img || img->ok==0 ) {
                mError = true;
                mOk = false;
                return mOk;
        }
-       if( img->ibuf==0 ) {
-               load_image(img, IB_rect, "", 0);
-               if(img->ibuf==0) {
-                       img->ok = 0;
-                       mError = true;
-                       mOk = false;
-                       return mOk;
-               } 
+       ibuf= BKE_image_get_ibuf(img, NULL);
+       if( ibuf==NULL ) {
+               img->ok = 0;
+               mError = true;
+               mOk = false;
+               return mOk;
        }
        mTexture = img->bindcode;
 
@@ -119,7 +119,7 @@ bool BL_Texture::InitFromImage(int unit,  Image *img, bool mipmap)
        }
        mNeedsDeleted = 1;
        glGenTextures(1, (GLuint*)&mTexture);
-       InitGLTex(img->ibuf->rect, img->ibuf->x, img->ibuf->y, mipmap);
+       InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap);
        Validate();
        return mOk;
 }
@@ -187,15 +187,12 @@ bool BL_Texture::InitCubeMap(int unit,  EnvMap *cubemap )
                mOk = false;
                return mOk;
        }
-
-       if( cubemap->ima->ibuf==0 )  {
-               load_image(cubemap->ima, IB_rect, "", 0);
-               if(cubemap->ima->ibuf==0) {
-                       cubemap->ima->ok = 0;
-                       mError = true;
-                       mOk = false;
-                       return mOk;
-               }
+       ImBuf *ibuf= BKE_image_get_ibuf(cubemap->ima, NULL);
+       if( ibuf==0 )  {
+               cubemap->ima->ok = 0;
+               mError = true;
+               mOk = false;
+               return mOk;
        }
 
        EnvMap *CubeMap = cubemap;
@@ -216,12 +213,9 @@ bool BL_Texture::InitCubeMap(int unit,  EnvMap *cubemap )
                my_envmap_split_ima(CubeMap);
        }
 
-       int x = CubeMap->ima->ibuf->x;
-       int y = CubeMap->ima->ibuf->y;
-
        // -----------------------------------
-       x       = CubeMap->cube[0]->ibuf->x;
-       y       = CubeMap->cube[0]->ibuf->y;
+       int x   = CubeMap->cube[0]->x;
+       int y   = CubeMap->cube[0]->y;
 
        // check the first image, and assume the rest
        if (!is_pow2(x) || !is_pow2(y)) {
@@ -236,10 +230,10 @@ bool BL_Texture::InitCubeMap(int unit,  EnvMap *cubemap )
 
 #define SetCubeMapFace(face, num)      \
        glTexImage2D(face, 0,GL_RGBA,   \
-       CubeMap->cube[num]->ibuf->x,    \
-       CubeMap->cube[num]->ibuf->y,    \
+       CubeMap->cube[num]->x,  \
+       CubeMap->cube[num]->y,  \
        0, GL_RGBA, GL_UNSIGNED_BYTE,   \
-       CubeMap->cube[num]->ibuf->rect)
+       CubeMap->cube[num]->rect)
 
        SetCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 5);
        SetCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, 3);
@@ -625,38 +619,34 @@ extern "C" {
 void my_envmap_split_ima(EnvMap *env)
 {
        ImBuf *ibuf;
-       Image *ima;
        int dx, part;
        
        my_free_envmapdata(env);        
        
-       dx= env->ima->ibuf->y;
+       dx= ibuf->y;
        dx/= 2;
-       if(3*dx != env->ima->ibuf->x) {
+       if(3*dx != ibuf->x) {
                printf("Incorrect envmap size\n");
                env->ok= 0;
                env->ima->ok= 0;
        }
        else {
                for(part=0; part<6; part++) {
-                       ibuf= IMB_allocImBuf(dx, dx, 24, IB_rect, 0);
-                       ima= (Image*)MEM_callocN(sizeof(Image), "image");
-                       ima->ibuf= ibuf;
-                       ima->ok= 1;
-                       env->cube[part]= ima;
+                       env->cube[part]= ibuf= IMB_allocImBuf(dx, dx, 24, IB_rect, 0);
                }
-               IMB_rectcpy(env->cube[0]->ibuf, env->ima->ibuf, 
-                       0, 0, 0, 0, dx, dx);
-               IMB_rectcpy(env->cube[1]->ibuf, env->ima->ibuf, 
-                       0, 0, dx, 0, dx, dx);
-               IMB_rectcpy(env->cube[2]->ibuf, env->ima->ibuf, 
-                       0, 0, 2*dx, 0, dx, dx);
-               IMB_rectcpy(env->cube[3]->ibuf, env->ima->ibuf, 
-                       0, 0, 0, dx, dx, dx);
-               IMB_rectcpy(env->cube[4]->ibuf, env->ima->ibuf, 
-                       0, 0, dx, dx, dx, dx);
-               IMB_rectcpy(env->cube[5]->ibuf, env->ima->ibuf, 
-                       0, 0, 2*dx, dx, dx, dx);
+               IMB_rectcpy(env->cube[0], ibuf, 
+                                       0, 0, 0, 0, dx, dx);
+               IMB_rectcpy(env->cube[1], ibuf, 
+                                       0, 0, dx, 0, dx, dx);
+               IMB_rectcpy(env->cube[2], ibuf, 
+                                       0, 0, 2*dx, 0, dx, dx);
+               IMB_rectcpy(env->cube[3], ibuf, 
+                                       0, 0, 0, dx, dx, dx);
+               IMB_rectcpy(env->cube[4], ibuf, 
+                                       0, 0, dx, dx, dx, dx);
+               IMB_rectcpy(env->cube[5], ibuf, 
+                                       0, 0, 2*dx, dx, dx, dx);
+               
                env->ok= 2;
        }
 }
@@ -664,19 +654,13 @@ void my_envmap_split_ima(EnvMap *env)
 
 void my_free_envmapdata(EnvMap *env)
 {
-       Image *ima;
-       unsigned int a, part;
+       unsigned int part;
        
        for(part=0; part<6; part++) {
-               ima= env->cube[part];
-               if(ima) {
-                       if(ima->ibuf) IMB_freeImBuf(ima->ibuf);
-
-                       for(a=0; a<BLI_ARRAY_NELEMS(ima->mipmap); a++) {
-                               if(ima->mipmap[a]) IMB_freeImBuf(ima->mipmap[a]);
-                       }
-                       MEM_freeN(ima);
-                       env->cube[part]= 0;
+               ImBuf *ibuf= env->cube[part];
+               if(ibuf) {
+                       IMB_freeImBuf(ibuf);
+                       env->cube[part]= NULL;
                }
        }
        env->ok= 0;