Biiig commit! Thanks to 2-3 weeks of cvs freeze...
authorTon Roosendaal <ton@blender.org>
Mon, 27 Dec 2004 19:28:52 +0000 (19:28 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 27 Dec 2004 19:28:52 +0000 (19:28 +0000)
Render:
- New; support for dual CPU render (SDL thread)
  Currently only works with alternating scanlines, but gives excellent
  performance. For both normal render as unified implemented.
  Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
  getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
  OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
  with chars or shorts.
- Made normal render and unified render use same code for sky and halo
  render, giving equal (and better) results for halo render. Old render
  now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
  after render. Using PostProcess menu you will note an immediate re-
  display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options

- Render module is still not having a "nice" API, but amount of dependencies
  went down a lot. Next todo: remove abusive "previewrender" code.
  The last main global in Render (struct Render) now can be re-used for fully
  controlling a render, to allow multiple "instances" of render to open.

- Renderwindow now displays a smal bar on top with the stats, and keeps the
  stats after render too. Including "spare" page support.
  Not only easier visible that way, but also to remove the awkward code that
  was drawing stats in the Info header (extreme slow on some ATIs too)

- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
  defines.

- I might have forgotten stuff... and will write a nice doc on the architecture!

119 files changed:
COPYING
SConstruct
release/Makefile
release/plugins/bmake
source/blender/blenkernel/BKE_bad_level_calls.h
source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/BKE_osa_types.h [deleted file]
source/blender/blenkernel/BKE_packedFile.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_utildefines.h
source/blender/blenkernel/bad_level_call_stubs/stubs.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/exotic.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/texture.c
source/blender/blenlib/BLI_arithb.h
source/blender/blenlib/intern/arithb.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/include/BIF_meshtools.h
source/blender/include/BIF_renderwin.h
source/blender/include/BSE_sequence.h
source/blender/include/blendef.h
source/blender/include/butspace.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_texture_types.h
source/blender/python/api2_2x/sceneRender.c
source/blender/render/SConscript
source/blender/render/extern/include/render.h
source/blender/render/extern/include/render_types.h
source/blender/render/intern/include/envmap.h
source/blender/render/intern/include/gammaCorrectionTables.h
source/blender/render/intern/include/initrender.h
source/blender/render/intern/include/jitter.h
source/blender/render/intern/include/old_zbuffer_types.h [deleted file]
source/blender/render/intern/include/pixelblending.h
source/blender/render/intern/include/pixelblending_types.h [deleted file]
source/blender/render/intern/include/pixelshading.h
source/blender/render/intern/include/render_intern.h [deleted file]
source/blender/render/intern/include/rendercore.h
source/blender/render/intern/include/rendercore_int.h [deleted file]
source/blender/render/intern/include/shadbuf.h
source/blender/render/intern/include/texture.h
source/blender/render/intern/include/vanillaRenderPipe.h
source/blender/render/intern/include/vanillaRenderPipe_int.h [deleted file]
source/blender/render/intern/include/zbuf.h
source/blender/render/intern/include/zbuf_int.h [deleted file]
source/blender/render/intern/source/Makefile
source/blender/render/intern/source/RE_callbacks.c
source/blender/render/intern/source/edgeRender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/errorHandler.c
source/blender/render/intern/source/gammaCorrectionTables.c
source/blender/render/intern/source/imagetexture.c [new file with mode: 0644]
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/jitter.c
source/blender/render/intern/source/pixelblending.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/ray.c
source/blender/render/intern/source/renderHelp.c
source/blender/render/intern/source/renderPreAndPost.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/renderdatabase.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/texture.c
source/blender/render/intern/source/vanillaRenderPipe.c
source/blender/render/intern/source/zbuf.c
source/blender/render/intern/source/zbufferdatastruct.c
source/blender/renderconverter/RE_renderconverter.h
source/blender/renderconverter/intern/convertBlenderScene.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_scene.c
source/blender/src/drawimage.c
source/blender/src/drawmesh.c
source/blender/src/drawobject.c
source/blender/src/drawseq.c
source/blender/src/drawview.c
source/blender/src/editaction.c
source/blender/src/editface.c
source/blender/src/editipo.c
source/blender/src/editlattice.c
source/blender/src/editmball.c
source/blender/src/editmesh.c
source/blender/src/editmesh_mods.c
source/blender/src/editobject.c
source/blender/src/editoops.c
source/blender/src/editscreen.c
source/blender/src/editseq.c
source/blender/src/editsima.c
source/blender/src/filesel.c
source/blender/src/header_action.c
source/blender/src/header_image.c
source/blender/src/header_info.c
source/blender/src/header_nla.c
source/blender/src/headerbuttons.c
source/blender/src/meshtools.c
source/blender/src/previewrender.c
source/blender/src/renderwin.c
source/blender/src/resources.c
source/blender/src/screendump.c
source/blender/src/seqaudio.c
source/blender/src/sequence.c
source/blender/src/toets.c
source/blender/src/toolbox.c
source/blender/src/usiblender.c
source/blender/src/view.c
source/blender/src/writeavicodec.c
source/blender/src/writeimage.c
source/blender/yafray/intern/export_File.cpp
source/blender/yafray/intern/export_Plugin.cpp
source/creator/creator.c

diff --git a/COPYING b/COPYING
index f7d3a5add07db36d0217f324ee907c73f33839b1..232ee776d872364496fa16568dba5b1ed88ea112 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,3 @@
 Please read over both of the following files:
-intern/GPL-license.txt
-intern/BL-license.txt
+doc/GPL-license.txt
+doc/BL-license.txt
index 0b55b67ebfacaac70ecb771c6dadda753f2d4e8a..f5b01816f7c9ccc5af07765b7940d0145a0f0e83 100644 (file)
@@ -1016,6 +1016,7 @@ if bs_globals.enable_clean==0: # only read SConscripts when not cleaning, this t
        Export ('extra_includes')
        Export ('user_options_dict')
        Export ('library_env')
+       Export ('sdl_env')
        
        BuildDir (bs_globals.root_build_dir+'/extern', 'extern', duplicate=0)
        SConscript (bs_globals.root_build_dir+'extern/SConscript')
index 65e84c30a974279992cd6de0fc579c32f1e6eef1..767518ffad09282526e51677e9dd7fe144ca97d2 100644 (file)
@@ -145,6 +145,7 @@ endif
 
     ifeq ($(OS),darwin)
        @echo "----> Move .blender to .app/Contents/MacOS/"
+       @rm -fr $(DISTDIR)/blender$(EXT0)/Contents/MacOS/.blender
        @mv $(DISTDIR)/.blender $(DISTDIR)/blender$(EXT0)/Contents/MacOS/
     endif
 
index 50f274ef3959422be96d22314a0eb6496a303d46..6e65f0bcbc84ae05d642dc1283d3dfe8f1a816a9 100644 (file)
@@ -74,7 +74,7 @@ elif ( test $UNAME = "Darwin" ) then
         CC="cc";
         CFLAGS="-fPIC -funsigned-char -O2 -fno-common";
         LD="cc";
-        LDFLAGS="-flat_namespace -bundle -bundle_loader ../../blender.app/Contents/MacOS/blender -ldl -lm";
+        LDFLAGS="-flat_namespace -bundle -bundle_loader ../../blender.app/Contents/MacOS/blender -lm";
         EXT="so";
 fi
 
index 8a875916a26085d2d1becf78d590bb796ad65250..709e9f87cbb86b9e56a5a29625e5af0546c58508 100644 (file)
@@ -133,12 +133,8 @@ void    RE_free_envmap(struct EnvMap *env);
 struct EnvMap *RE_copy_envmap(struct EnvMap *env);
 void    RE_free_envmapdata(struct EnvMap *env);
 int     RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt);
-void    RE_calc_R_ref(void);
 extern char texstr[20][12];    /* buttons.c */
 
-/* memory for O is declared in the render module... */
-#include "BKE_osa_types.h"
-extern Osa O;
 
 /* editsca.c */
 void make_unique_prop_names(char *str);
index d0a9c1e5c6a0fd124aa401a0257fd90a0f4c6ec7..7b76a438e59cdf3286dd0218c8beae8d8f1d6c96 100644 (file)
@@ -42,6 +42,9 @@ struct ListBase;
 struct BezTriple;
 struct BevList;
 
+#define KNOTSU(nu)         ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
+#define KNOTSV(nu)         ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
+
 
 int copyintoExtendedArray(float *old, int oldx, int oldy, float *newp, int newx, int newy);
 void unlink_curve( struct Curve *cu);
index 34cb2c64ec6864e971d8c815b0e3a04e0d7b2e42..95883501f5569b5d3376be67258a5b708c177da1 100644 (file)
 #define DL_FRONT_CURVE 4
 #define DL_BACK_CURVE  8
 
+/* This should, of course, become a function */
+#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev)           \
+\
+if( (cyclv)==0 && a==(sizev)-1) break;             \
+if(cyclu) {                                                \
+       p1= sizeu*a;                                        \
+               p2= p1+ sizeu-1;                                    \
+                       p3= p1+ sizeu;                                      \
+                               p4= p2+ sizeu;                                      \
+                                       b= 0;                                               \
+}                                                          \
+else {                                             \
+       p2= sizeu*a;                                        \
+               p1= p2+1;                                           \
+                       p4= p2+ sizeu;                                      \
+                               p3= p1+ sizeu;                                      \
+                                       b= 1;                                               \
+}                                                          \
+if( (cyclv) && a==sizev-1) {                       \
+       p3-= sizeu*sizev;                                   \
+               p4-= sizeu*sizev;                                   \
+}
+
+
 /* prototypes */
 
 struct Object;
index 0196d8bc3916fdc5701d9ed62bf9d4e5a86c4e20..cf642932447fa13680af52d6c2495c3ffb69fb75 100644 (file)
@@ -93,6 +93,8 @@ typedef struct Global {
     
     short machine, afbreek, moving, colact, zbuf;
     short qual, background, imagewin, animspeed;
+       short winpos, displaymode;      /* used to be in Render */
+       
        /**
         * The current version of Blender.
         */
index fd278aa5329459568c8400e1f9449df1e653ec9c..2da0dcb5f5a558c8d969285cfdee7284353bc13c 100644 (file)
@@ -47,18 +47,12 @@ void free_image(struct Image *me);
 void free_image_buffers(struct Image *ima);
 struct Image *add_image(char *name);
 void free_unused_animimages(void);
+
 void makepicstring(char *string, int frame);
 struct anim *openanim(char * name, int flags);
-int calcimanr(int cfra, struct Tex *tex);
-void do_laseroptics_patch(struct ImBuf *ibuf);
-void de_interlace_ng(struct ImBuf *ibuf);
-void de_interlace_st(struct ImBuf *ibuf);
-void load_image(struct Image * ima, int flags, char *relabase, int framenum);
 void ima_ibuf_is_nul(struct Tex *tex);
-int imagewrap(struct Tex *tex, float *texvec);
-int imagewraposa(struct Tex *tex, float *texvec, float *dxt, float *dyt);
+void load_image(struct Image * ima, int flags, char *relabase, int framenum);
 void converttopremul(struct ImBuf *ibuf);
-void makemipmap(struct Image *ima);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/BKE_osa_types.h b/source/blender/blenkernel/BKE_osa_types.h
deleted file mode 100644 (file)
index 28d4147..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * blenlib/BKE_osa_types.h (mar-2001 nzc)
- *     
- * $Id$ 
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-#ifndef BKE_OSA_TYPES_H
-#define BKE_OSA_TYPES_H
-
-/*  typedef struct Osa */
-typedef struct RE_Osa
-{
-       float dxco[3], dyco[3];
-       float dxlo[3], dylo[3], dxgl[3], dygl[3], dxuv[3], dyuv[3];
-       float dxref[3], dyref[3], dxorn[3], dyorn[3];
-       float dxno[3], dyno[3], dxview, dyview;
-       float dxlv[3], dylv[3];
-       float dxwin[3], dywin[3];
-       float dxsticky[3], dysticky[3];
-       float dxrefract[3], dyrefract[3];
-} Osa;
-
-/*  extern Osa O;  */
-/* This one used to be done in render/extern/include/render.h, because
-    memory was allocated in that module. (nzc)*/
-
-#endif
-
index bb605ba55a09bf8881edc12b34db2450b5a67980..270a0492f9123c172850d892cb5d2a06e8a1d485 100644 (file)
@@ -34,6 +34,9 @@
 #ifndef BKE_PACKEDFILE_H
 #define BKE_PACKEDFILE_H
 
+#define RET_OK 0
+#define RET_ERROR 1
+
 struct PackedFile;
 struct VFont;
 struct bSample;
index 9d1a23952ad8cfc901ee004c19314747b4ec6edf..538912a1f406e7892fcf72c33136aa7d37910f8f 100644 (file)
@@ -40,6 +40,21 @@ struct Base;
 struct AviCodecData;
 struct QuicktimeCodecData;
 
+/* sequence related defines */
+#define WHILE_SEQ(base)        {                                                                                       \
+       int totseq_, seq_; Sequence **seqar;    \
+               build_seqar( base,  &seqar, &totseq_);  \
+                       for(seq_ = 0; seq_ < totseq_; seq_++) { \
+                               seq= seqar[seq_];
+                               
+                               
+#define END_SEQ                                        }                                               \
+                               if(seqar) MEM_freeN(seqar);             \
+}
+
+
+
+
 void free_avicodecdata(struct AviCodecData *acd);
 void free_qtcodecdata(struct QuicktimeCodecData *acd);
 void free_scene(struct Scene *me);
index c32e767ab92e9ede5b245a4cf32feb96e29a918c..b1f084fd566269ef7a9464d60bb1c26c3af226e7 100644 (file)
 #define TRUE 1
 #endif
 
+/* also fill in structs itself, dna cannot handle defines, duplicate in blendef.h still */
+#ifndef FILE_MAXDIR
+#define FILE_MAXDIR                    160
+#define FILE_MAXFILE           80
+#endif
+
 #define ELEM(a, b, c)           ( (a)==(b) || (a)==(c) )
 #define ELEM3(a, b, c, d)       ( ELEM(a, b, c) || (a)==(d) )
 #define ELEM4(a, b, c, d, e)    ( ELEM(a, b, c) || ELEM(a, d, e) )
 #define MAX3(x,y,z)             MAX2( MAX2((x),(y)) , (z) )
 #define MAX4(x,y,z,a)           MAX2( MAX2((x),(y)) , MAX2((z),(a)) )
 
-#define SWAP(type, a, b)        { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
-
-#define ABS(a)                                 ( (a)<0 ? (-(a)) : (a) )
-
-#define VECCOPY(v1,v2)          {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
-#define QUATCOPY(v1,v2)         {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
-
-#define VECADD(v1,v2,v3)       {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
-#define VECSUB(v1,v2,v3)       {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
-
-#define INPR(v1, v2)           ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
-
 #define INIT_MINMAX(min, max) (min)[0]= (min)[1]= (min)[2]= 1.0e30; (max)[0]= (max)[1]= (max)[2]= -1.0e30;
 
 #define INIT_MINMAX2(min, max) (min)[0]= (min)[1]= 1.0e30; (max)[0]= (max)[1]= -1.0e30;
                                                          if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
                                                          if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];
 
-/* interferes elsewhere */
-/* also fill in structs itself, dna cannot handle defines */
-#define FILE_MAXDIR                    160
-#define FILE_MAXFILE           80
+#define MINSIZE(val, size)     ( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val)))
+
+/* some math and copy defines */
+
+#define SWAP(type, a, b)        { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
+
+#define ABS(a)                                 ( (a)<0 ? (-(a)) : (a) )
+
+#define VECCOPY(v1,v2)          {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
+#define QUATCOPY(v1,v2)         {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
+#define LONGCOPY(a, b, c)      {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
+
+
+#define VECADD(v1,v2,v3)       {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
+#define VECSUB(v1,v2,v3)       {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
+
+#define INPR(v1, v2)           ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
 
 
 /* some misc stuff.... */
 #define CLAMP(a, b, c)         if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
+#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a))
+#define CLAMPTEST(a, b, c)     if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);}
+
+#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1)
 
-#define KNOTSU(nu)        ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-#define KNOTSV(nu)        ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )  
 
 /* this weirdo pops up in two places ... */
 #if !defined(WIN32) && !defined(__BeOS)
 
 #define ENDB MAKE_ID('E','N','D','B')
 
-/* This should, of course, become a function */
-#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev)           \
-                                                           \
-    if( (cyclv)==0 && a==(sizev)-1) break;                 \
-    if(cyclu) {                                                    \
-       p1= sizeu*a;                                        \
-       p2= p1+ sizeu-1;                                    \
-       p3= p1+ sizeu;                                      \
-       p4= p2+ sizeu;                                      \
-       b= 0;                                               \
-    }                                                      \
-    else {                                                 \
-       p2= sizeu*a;                                        \
-       p1= p2+1;                                           \
-       p4= p2+ sizeu;                                      \
-       p3= p1+ sizeu;                                      \
-       b= 1;                                               \
-    }                                                      \
-    if( (cyclv) && a==sizev-1) {                           \
-       p3-= sizeu*sizev;                                   \
-       p4-= sizeu*sizev;                                   \
-    }
 
 /* This one rotates the bytes in an int */
 #define SWITCH_INT(a) { \
     s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
     s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
 
-/* More brain damage. Only really used by packedFile.c  */
-// return values
-#define RET_OK 0
-#define RET_ERROR 1
-/* and these aren't used at all */
-/*  #define RET_CANCEL 2 */
-/*  #define RET_YES (1 == 1) */
-/*  #define RET_NO (1 == 0) */
-
-/* sequence related defines */
-#define WHILE_SEQ(base)        {                                                                                       \
-                                                       int totseq_, seq_; Sequence **seqar;    \
-                                                       build_seqar( base,  &seqar, &totseq_);  \
-                                                       for(seq_ = 0; seq_ < totseq_; seq_++) { \
-                                                                       seq= seqar[seq_];
-                                                               
-
-#define END_SEQ                                        }                                               \
-                                                       if(seqar) MEM_freeN(seqar);             \
-                                                       }
-
-
-/* not really sure about these...  some kind of event codes ?*/ 
-/* INFO: 300 */
-/* pas op: ook in filesel.c en editobject.c */
-#define B_INFOSCR              301
-#define B_INFODELSCR   302
-#define B_INFOSCE              304
-#define B_INFODELSCE   305
-#define B_FILEMENU             306
-#define B_PACKFILE             307
-
-/* From iff.h, but seemingly detached from anything else... To which
- * encoding scheme do they belong? */
-#define AMI        (1 << 31)
-#define CDI        (1 << 30)
-#define Anim   (1 << 29)
-#define TGA        (1 << 28)
-#define JPG            (1 << 27)
-#define TIM        (1 << 26)
-
-#define TIM_CLUT       (010)
-#define TIM_4          (TIM | TIM_CLUT | 0)
-#define TIM_8          (TIM | TIM_CLUT | 1)
-#define TIM_16         (TIM | 2)
-#define TIM_24         (TIM | 3)
-
-#define RAWTGA (TGA | 1)
-
-#define JPG_STD        (JPG | (0 << 8))
-#define JPG_VID        (JPG | (1 << 8))
-#define JPG_JST        (JPG | (2 << 8))
-#define JPG_MAX        (JPG | (3 << 8))
-#define JPG_MSK        (0xffffff00)
-
-#define AM_ham     (0x0800 | AMI)
-#define AM_hbrite   (0x0080 | AMI)
-#define AM_lace            (0x0004 | AMI)
-#define AM_hires    (0x8000 | AMI)
-#define AM_hblace   (AM_hbrite | AM_lace)
-#define AM_hilace   (AM_hires | AM_lace)
-#define AM_hamlace  (AM_ham | AM_lace)
-
-#define RGB888 1
-#define RGB555 2
-#define DYUV   3
-#define CLUT8  4
-#define CLUT7  5
-#define CLUT4  6
-#define CLUT3  7
-#define RL7    8
-#define RL3    9
-#define MPLTE  10
-
-#define DYUV1  0
-#define DYUVE  1
-
-#define CD_rgb8                (RGB888 | CDI)
-#define CD_rgb5                (RGB555 | CDI)
-#define CD_dyuv                (DYUV | CDI)
-#define CD_clut8       (CLUT8 | CDI)
-#define CD_clut7       (CLUT7 | CDI)
-#define CD_clut4       (CLUT4 | CDI)
-#define CD_clut3       (CLUT3 | CDI)
-#define CD_rl7         (RL7 | CDI)
-#define CD_rl3         (RL3 | CDI)
-#define CD_mplte       (MPLTE | CDI)
-
-#define C233   1
-#define YUVX   2
-#define HAMX   3
-#define TANX   4
-
-#define AN_c233                        (Anim | C233)
-#define AN_yuvx                        (Anim | YUVX)
-#define AN_hamx                        (Anim | HAMX)
-#define AN_tanx                        (Anim | TANX)
-
-#define IMAGIC         0732
-
-/* This used to reside in render.h. It does some texturing. */
-#define BRICON         Tin= (Tin-0.5)*tex->contrast+tex->bright-0.5; \
-                                       if(Tin<0.0) Tin= 0.0; else if(Tin>1.0) Tin= 1.0;
-
-#define BRICONRGB      Tr= tex->rfac*((Tr-0.5)*tex->contrast+tex->bright-0.5); \
-                                       if(Tr<0.0) Tr= 0.0; \
-                                       Tg= tex->gfac*((Tg-0.5)*tex->contrast+tex->bright-0.5); \
-                                       if(Tg<0.0) Tg= 0.0; \
-                                       Tb= tex->bfac*((Tb-0.5)*tex->contrast+tex->bright-0.5); \
-                                       if(Tb<0.0) Tb= 0.0; 
-
-/* mystifying stuff from blendef... */
-#define SELECT                 1
-#define ACTIVE                 2
-#define NOT_YET                        0
-
-/* ???? */
+
+/* Bit operations */
 #define BTST(a,b)     ( ( (a) & 1<<(b) )!=0 )   
 #define BSET(a,b)     ( (a) | 1<<(b) )
+#define BCLR(a,b)      ( (a) & ~(1<<(b)) )
+/* bit-row */
+#define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) )
 
-/* needed for material.c*/
-#define REDRAWBUTSMAT         0x4015
 
-/* useless game shit */
-#define MA_FH_NOR      2
+#ifdef GS
+#undef GS
+#endif
+#define GS(a)  (*((short *)(a)))
 
 #endif
 
index 13218846b59b1bc9e41ee3b69330322e98a2f317..4da7d2a2f20dbff09b47e407301b50c73aea14c0 100644 (file)
@@ -195,10 +195,9 @@ int BPY_call_importloader(char *name)
 #define INT    96
        /* struct EnvMap; */
        /* struct Tex; */
-float Ta, Tb, Tg, Tin, Tr;
 
 void do_material_tex(ShadeInput *shi){}
-void externtex(struct MTex *mtex, float *vec){}
+void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta){}
 void init_render_textures(void){}
 void end_render_textures(void){}
 
@@ -210,9 +209,7 @@ int     RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt){
    return 0;
 }
 
-void    RE_calc_R_ref(void){}
 char texstr[20][12];   /* buttons.c */
-Osa O;
 
 /* editsca.c */
 void make_unique_prop_names(char *str) {}
index 69363f4d9af0488ad5059659eab8fea3a0d7a666..db8653f0abe390998c0b8e660cd93a721999652b 100644 (file)
@@ -91,6 +91,7 @@
 #include "BIF_mainqueue.h" // mainqenter for onload script
 #include "mydevice.h"
 #include "nla.h"
+#include "blendef.h"
 
 Global G;
 UserDef U;
@@ -318,8 +319,8 @@ static void setup_app_data(BlendFileData *bfd, char *filename)
                G.scene= curscene;
        }
        else {
-               R.winpos= bfd->winpos;
-               R.displaymode= bfd->displaymode;
+               G.winpos= bfd->winpos;
+               G.displaymode= bfd->displaymode;
                G.fileflags= bfd->fileflags;
                G.curscreen= bfd->curscreen;
                G.scene= G.curscreen->scene;
index 922b4d5cf78251d552d16df082939493aaa913c8..228588e2c4a43fef5bd9eeb163a47b3417b795c0 100644 (file)
@@ -521,18 +521,24 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
        int a, back;
 
        if(ma==0) return;
+       
        shi.mat= ma;
-       shi.matren= ma->ren;
        shi.vlr= NULL;  // have to do this!
-       ma= shi.matren;
+       
+       // copy all relevant material vars, note, keep this synced with render_types.h
+       memcpy(&shi.r, &shi.mat->r, 23*sizeof(float));
+       // set special cases:
+       shi.har= shi.mat->har;
+       
        shi.osatex= 0;  // also prevents reading vlr
+       
        VECCOPY(shi.vn, nor);
        
        if(ma->mode & MA_VERTEXCOLP) {
                if(vertcol) {
-                       ma->r= vertcol[3]/255.0;
-                       ma->g= vertcol[2]/255.0;
-                       ma->b= vertcol[1]/255.0;
+                       shi.r= vertcol[3]/255.0;
+                       shi.g= vertcol[2]/255.0;
+                       shi.b= vertcol[1]/255.0;
                }
        }
        
@@ -565,24 +571,19 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                        shi.ref[2]= (-1.0+inp*shi.vn[2]);
                }
 
-               if(ma->mode & MA_VERTEXCOLP) {
-                       shi.mat->r= ma->r;
-                       shi.mat->g= ma->g;
-                       shi.mat->b= ma->b;
-               }
                do_material_tex(&shi);
        }
 
        if(ma->mode & MA_SHLESS) {
                if(vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) {
-                       col1[3]= vertcol[3]*ma->r;
-                       col1[2]= vertcol[2]*ma->g;
-                       col1[1]= vertcol[1]*ma->b;
+                       col1[3]= vertcol[3]*shi.r;
+                       col1[2]= vertcol[2]*shi.g;
+                       col1[1]= vertcol[1]*shi.b;
                }
                else {
-                       col1[3]= (255.0*ma->r);
-                       col1[2]= (255.0*ma->g);
-                       col1[1]= (255.0*ma->b);
+                       col1[3]= (255.0*shi.r);
+                       col1[2]= (255.0*shi.g);
+                       col1[1]= (255.0*shi.b);
                }
                if(col2) {
                        col2[3]= col1[3];
@@ -593,14 +594,14 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
        }
 
        if( vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) {
-               diff1[0]= diff2[0]= ma->r*(ma->emit+vertcol[3]/255.0);
-               diff1[1]= diff2[1]= ma->g*(ma->emit+vertcol[2]/255.0);
-               diff1[2]= diff2[2]= ma->b*(ma->emit+vertcol[1]/255.0);
+               diff1[0]= diff2[0]= shi.r*(shi.emit+vertcol[3]/255.0);
+               diff1[1]= diff2[1]= shi.g*(shi.emit+vertcol[2]/255.0);
+               diff1[2]= diff2[2]= shi.b*(shi.emit+vertcol[1]/255.0);
        }
        else {
-               diff1[0]= diff2[0]= ma->r*ma->emit;
-               diff1[1]= diff2[1]= ma->g*ma->emit;
-               diff1[2]= diff2[2]= ma->b*ma->emit;
+               diff1[0]= diff2[0]= shi.r*shi.emit;
+               diff1[1]= diff2[1]= shi.g*shi.emit;
+               diff1[2]= diff2[2]= shi.b*shi.emit;
        }
        
        shi.view[0]= 0.0;
@@ -679,7 +680,7 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                        back= 1;
                        is= -is;
                }
-               inp= is*lampdist*ma->ref;
+               inp= is*lampdist*shi.refl;
 
                if(back==0) {
                        add_to_diffuse(diff1, &shi, is, inp*fl->r, inp*fl->g, inp*fl->b);
@@ -692,20 +693,20 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                        //diff2[1]+= inp*fl->g;
                        //diff2[2]+= inp*fl->b;
                }
-               if(ma->spec && (fl->mode & LA_NO_SPEC)==0) {
+               if(shi.spec!=0.0 && (fl->mode & LA_NO_SPEC)==0) {
                        float specfac;
                        
                        if(ma->spec_shader==MA_SPEC_PHONG) 
-                               specfac= Phong_Spec(nor, lv, shi.view, ma->har);
+                               specfac= Phong_Spec(nor, lv, shi.view, shi.har);
                        else if(ma->spec_shader==MA_SPEC_COOKTORR) 
-                               specfac= CookTorr_Spec(nor, lv, shi.view, ma->har);
+                               specfac= CookTorr_Spec(nor, lv, shi.view, shi.har);
                        else if(ma->spec_shader==MA_SPEC_BLINN) 
-                               specfac= Blinn_Spec(nor, lv, shi.view, ma->refrac, (float)ma->har);
+                               specfac= Blinn_Spec(nor, lv, shi.view, ma->refrac, (float)shi.har);
                        else 
                                specfac= Toon_Spec(nor, lv, shi.view, ma->param[2], ma->param[3]);
                        
                        if(specfac>0) {
-                               t= specfac*ma->spec*lampdist;
+                               t= specfac*shi.spec*lampdist;
                                if(back==0) {
                                        if(ma->mode & MA_RAMP_SPEC) {
                                                float spec[3];
@@ -715,9 +716,9 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                                                isb+= t*(fl->b * spec[2]);
                                        }
                                        else {
-                                               isr+= t*(fl->r * ma->specr);
-                                               isg+= t*(fl->g * ma->specg);
-                                               isb+= t*(fl->b * ma->specb);
+                                               isr+= t*(fl->r * shi.specr);
+                                               isg+= t*(fl->g * shi.specg);
+                                               isb+= t*(fl->b * shi.specb);
                                        }
                                }
                                else if(col2) {
@@ -729,9 +730,9 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                                                isb1+= t*(fl->b * spec[2]);
                                        }
                                        else {
-                                               isr1+= t*(fl->r * ma->specr);
-                                               isg1+= t*(fl->g * ma->specg);
-                                               isb1+= t*(fl->b * ma->specb);
+                                               isr1+= t*(fl->r * shi.specr);
+                                               isg1+= t*(fl->g * shi.specg);
+                                               isb1+= t*(fl->b * shi.specb);
                                        }
                                }
                        }
@@ -742,13 +743,13 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
        if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(diff1, &shi);
        if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(&isr, &isg, &isb, &shi);
 
-       a= 256*(diff1[0] + ma->ambr +isr);
+       a= 256*(diff1[0] + shi.ambr +isr);
        if(a>255) col1[3]= 255; 
        else col1[3]= a;
-       a= 256*(diff1[1] + ma->ambg +isg);
+       a= 256*(diff1[1] + shi.ambg +isg);
        if(a>255) col1[2]= 255; 
        else col1[2]= a;
-       a= 256*(diff1[2] + ma->ambb +isb);
+       a= 256*(diff1[2] + shi.ambb +isb);
        if(a>255) col1[1]= 255; 
        else col1[1]= a;
 
@@ -756,13 +757,13 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
                if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(diff2, &shi);
                if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(&isr1, &isg1, &isb1, &shi);
                
-               a= 256*(diff2[0] + ma->ambr +isr1);
+               a= 256*(diff2[0] + shi.ambr +isr1);
                if(a>255) col2[3]= 255; 
                else col2[3]= a;
-               a= 256*(diff2[1] + ma->ambg +isg1);
+               a= 256*(diff2[1] + shi.ambg +isg1);
                if(a>255) col2[2]= 255; 
                else col2[2]= a;
-               a= 256*(diff2[2] + ma->ambb +isb1);
+               a= 256*(diff2[2] + shi.ambb +isb1);
                if(a>255) col2[1]= 255; 
                else col2[1]= a;
        }
@@ -935,7 +936,7 @@ void shadeDispList(Object *ob)
                ma= give_current_material(ob, a+1);
                if(ma) {
                        init_render_material(ma);
-                       if(ma->ren->texco & TEXCO_ORCO) need_orco= 1;
+                       if(ma->texco & TEXCO_ORCO) need_orco= 1;
                }
        }
 
@@ -2263,7 +2264,7 @@ void imagestodisplist(void)
        ListBase _wireframe, *wireframe;
        DispList *dl;
        Segment *seg;
-       float *data, xfac, yfac, xsi, ysi, vec[3];
+       float *data, xfac, yfac, xsi, ysi, vec[3], dum;
        int tot;
        
        _wireframe.first= 0;
@@ -2285,7 +2286,7 @@ void imagestodisplist(void)
                                        tex= ma->mtex[0]->tex;
                                        
                                        /* this takes care of correct loading of new imbufs */
-                                       externtex(ma->mtex[0], vec);
+                                       externtex(ma->mtex[0], vec, &dum, &dum, &dum, &dum, &dum);
                                        
                                        if(tex->type==TEX_IMAGE && tex->ima && tex->ima->ibuf) {                                
                                                
index 988d9abfd9b3e69b199b77d7c36ace1ca6f361af..fcadd35f427a71c5bfd19bcfd4df9ac8f6abb7d8 100644 (file)
 #include <math.h>
 #include <stdlib.h>
 
+#ifdef WIN32
+#include "BLI_winstuff.h"
+#endif
+
 #include "MEM_guardedalloc.h"
 #include "DNA_listBase.h"
 #include "DNA_effect_types.h"
@@ -71,6 +75,9 @@
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
+#include "render.h"  // externtex, bad level call (ton)
+
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -311,39 +318,38 @@ void where_is_particle(PartEff *paf, Particle *pa, float ctime, float *vec)
 
 void particle_tex(MTex *mtex, PartEff *paf, float *co, float *no)
 {                              
-       extern float Tin, Tr, Tg, Tb;
-       extern void externtex(struct MTex *mtex, float *vec);
+       float tin, tr, tg, tb, ta;
        float old;
        
-       externtex(mtex, co);
+       externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
 
        if(paf->texmap==PAF_TEXINT) {
-               Tin*= paf->texfac;
-               no[0]+= Tin*paf->defvec[0];
-               no[1]+= Tin*paf->defvec[1];
-               no[2]+= Tin*paf->defvec[2];
+               tin*= paf->texfac;
+               no[0]+= tin*paf->defvec[0];
+               no[1]+= tin*paf->defvec[1];
+               no[2]+= tin*paf->defvec[2];
        }
        else if(paf->texmap==PAF_TEXRGB) {
-               no[0]+= (Tr-0.5f)*paf->texfac;
-               no[1]+= (Tg-0.5f)*paf->texfac;
-               no[2]+= (Tb-0.5f)*paf->texfac;
+               no[0]+= (tr-0.5f)*paf->texfac;
+               no[1]+= (tg-0.5f)*paf->texfac;
+               no[2]+= (tb-0.5f)*paf->texfac;
        }
        else {  /* PAF_TEXGRAD */
                
-               old= Tin;
+               old= tin;
                co[0]+= paf->nabla;
-               externtex(mtex, co);
-               no[0]+= (old-Tin)*paf->texfac;
+               externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
+               no[0]+= (old-tin)*paf->texfac;
                
                co[0]-= paf->nabla;
                co[1]+= paf->nabla;
-               externtex(mtex, co);
-               no[1]+= (old-Tin)*paf->texfac;
+               externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
+               no[1]+= (old-tin)*paf->texfac;
                
                co[1]-= paf->nabla;
                co[2]+= paf->nabla;
-               externtex(mtex, co);
-               no[2]+= (old-Tin)*paf->texfac;
+               externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
+               no[2]+= (old-tin)*paf->texfac;
                
        }
 }
index 2410255c6af9f69922c2c11d31b4a20623e3778b..3347a193d802cfd67e7ddb8af9bf65190dd63cae 100644 (file)
 
 #include "BPY_extern.h"
 
+#include "blendef.h"
+
 static int is_dxf(char *str);
 static void dxf_read(char *filename);
 static int is_stl(char *str);
index 0663fb2244e8437643a84b66775c6ce4b9a90c20..50119cdf3a7c6fea67ad2caa04f3c1f609792aa5 100644 (file)
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 
-#include "DNA_texture_types.h"
 #include "DNA_image_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_packedFile_types.h"
 
 #include "BLI_blenlib.h"
 
-#include "BKE_bad_level_calls.h"
-#include "BKE_utildefines.h"
-
+#include "BKE_bmfont.h"
+#include "BKE_packedFile.h"
+#include "BKE_library.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
-
 #include "BKE_image.h"
-#include "BKE_bmfont.h"
-#include "BKE_screen.h"
+#include "BKE_scene.h"
 #include "BKE_texture.h"
-#include "BKE_packedFile.h"
-#include "BKE_library.h"
-
-void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2);
-void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2);
-float square_rctf(rctf *rf);
-float clipx_rctf(rctf *rf, float x1, float x2);
-float clipy_rctf(rctf *rf, float y1, float y2);
-void boxsample(struct ImBuf *ibuf,
-                          float minx, float miny, float maxx, float maxy,
-                          float *rcol, float *gcol, float *bcol, float *acol);
-void boxsampleclip(struct ImBuf *ibuf, rctf *rf, float *rcol,
-                                  float *gcol, float *bcol, float *acol);
-void filtersample(struct ImBuf *ibuf,
-                                 float fx, float fy,
-                                 float *rcol, float *gcol, float *bcol, float *acol);
-
-       
-
-/* If defined: check arguments on call */
-/*  #define IMAGE_C_ARG_CHECK */
-
-/* Communicate with texture channels. */
-extern float Tin, Tr, Tg, Tb, Ta;
-
-int Talpha;
-int imaprepeat, imapextend;
-
+#include "BKE_utildefines.h"
 
-/*
- * 
- *  Talpha==TRUE means: read alpha from image. This does not mean that Ta
- *  should not be used, here info can be stored about outside edge of an image!
- * 
- */
+/* bad level; call to free_realtime_image */
+#include "BKE_bad_level_calls.h"       
 
 void free_image_buffers(Image *ima)
 {
@@ -249,6 +212,7 @@ void makepicstring(char *string, int frame)
 
 /* ******** IMAGE WRAPPING INIT ************* */
 
+/* used by sequencer, texture */
 void converttopremul(struct ImBuf *ibuf)
 {
        int x, y, val;
@@ -282,29 +246,7 @@ void converttopremul(struct ImBuf *ibuf)
        }
 }
 
-
-
-void makemipmap(Image *ima)
-{
-       struct ImBuf *ibuf;
-       int minsize, curmap=0;
-
-       ibuf= ima->ibuf;
-       minsize= MIN2(ibuf->x, ibuf->y);
-
-       while(minsize>3 && curmap<BLI_ARRAY_NELEMS(ima->mipmap)) {
-
-               ibuf= IMB_dupImBuf(ibuf);
-               IMB_filter(ibuf);
-               ima->mipmap[curmap]= (struct ImBuf *)IMB_onehalf(ibuf);
-               IMB_freeImBuf(ibuf);
-               ibuf= ima->mipmap[curmap];
-               
-               curmap++;
-               minsize= MIN2(ibuf->x, ibuf->y);
-       }
-}
-
+/* used by sequencer, texture */
 struct anim *openanim(char * name, int flags)
 {
        struct anim * anim;
@@ -325,85 +267,36 @@ struct anim *openanim(char * name, int flags)
        return(anim);
 }
 
-int calcimanr(int cfra, Tex *tex)
-{
-       int imanr, len, a, fra, dur;
 
-       /* here (+fie_ima/2-1) makes sure that division happens correctly */
-       
-       if(tex->frames==0) return 1;
-       
-       cfra= cfra-tex->sfra+1;
-       
-       /* cyclic */
-       if(tex->len==0) len= (tex->fie_ima*tex->frames)/2;
-       else len= tex->len;
-       
-       if(tex->imaflag & TEX_ANIMCYCLIC) {
-               cfra= ( (cfra) % len );
-               if(cfra < 0) cfra+= len;
-               if(cfra==0) cfra= len;
-       }
-       
-       if(cfra<1) cfra= 1;
-       else if(cfra>len) cfra= len;
-       
-       /* convert current frame to current field */
-       cfra= 2*(cfra);
-       if(R.flag & R_SEC_FIELD) cfra++;
-       
-       /* transform to images space */
-       imanr= (cfra+tex->fie_ima-2)/tex->fie_ima;
-       if(imanr>tex->frames) imanr= tex->frames;
-       imanr+= tex->offset;
-       
-       if(tex->imaflag & TEX_ANIMCYCLIC) {
-               imanr= ( (imanr) % len );
-               while(imanr < 0) imanr+= len;
-               if(imanr==0) imanr= len;
-       }
+/*
+load_image handles reading the image from disk or from the packedfile.
+*/
 
-       /* are there images that last longer? */
-       for(a=0; a<4; a++) {
-               if(tex->fradur[a][0]) {
-                       
-                       fra= tex->fradur[a][0];
-                       dur= tex->fradur[a][1]-1;
-                       
-                       while(dur>0 && imanr>fra) {
-                               imanr--;
-                               dur--;
-                       }
-               }
-       }
+void load_image(Image * ima, int flags, char *relabase, int framenum)
+{
+       char name[FILE_MAXDIR + FILE_MAXFILE];
 
-       return imanr;
-}
+       if (ima->ibuf == NULL) {
 
-void do_laseroptics_patch(ImBuf *ibuf)
-{
-       char *rt;
-       float fac;
-       int a, val;
-       
-       rt= (char *)ibuf->rect;
-       a= ibuf->x*ibuf->y;
+               // is there a PackedFile with this image ?;
+               if (ima->packedfile) {
+                       ima->ibuf = IMB_ibImageFromMemory((int *) ima->packedfile->data, ima->packedfile->size, flags);
+               } else {
+                       strcpy(name, ima->name);
+                       BLI_convertstringcode(name, relabase, framenum);
 
-       if(ibuf->flags & IB_fields) a+= a;
+                       ima->ibuf = IMB_loadiffname(name , flags);
+               }
+               // check if the image is a font image...
+               // printf("Checking for font\n");
 
-       while(a--) {
-               
-               fac= (rt[1]+rt[2]+rt[3])/765.0f;
-               val= (int)((255.0/0.8)*(fac-0.1));
-               
-               if(val<0) val= 0; else if(val>255) val= 255;
-               
-               rt[0]= rt[1]= rt[2]= rt[3]= val;
-               
-               rt+= 4;
+               if (ima->ibuf) {
+                       detectBitmapFont(ima->ibuf);
+               }
        }
 }
 
+
 void de_interlace_ng(struct ImBuf *ibuf)       /* neogeo fields */
 {
        struct ImBuf * tbuf1, * tbuf2;
@@ -421,7 +314,7 @@ void de_interlace_ng(struct ImBuf *ibuf)    /* neogeo fields */
                /* These rectop calls are broken!!! I added a trailing 0 arg... */
                IMB_rectop(tbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
                IMB_rectop(tbuf2, ibuf, 0, 0, tbuf2->x, 0, 32767, 32767, IMB_rectcpy, 0);
-       
+               
                ibuf->x /= 2;
                IMB_rectop(ibuf, tbuf1, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
                IMB_rectop(ibuf, tbuf2, 0, tbuf2->y, 0, 0, 32767, 32767, IMB_rectcpy, 0);
@@ -449,7 +342,7 @@ void de_interlace_st(struct ImBuf *ibuf)    /* standard fields */
                /* These are brolenm as well... */
                IMB_rectop(tbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
                IMB_rectop(tbuf2, ibuf, 0, 0, tbuf2->x, 0, 32767, 32767, IMB_rectcpy, 0);
-       
+               
                ibuf->x /= 2;
                IMB_rectop(ibuf, tbuf2, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
                IMB_rectop(ibuf, tbuf1, 0, tbuf2->y, 0, 0, 32767, 32767, IMB_rectcpy, 0);
@@ -460,33 +353,6 @@ void de_interlace_st(struct ImBuf *ibuf)   /* standard fields */
        ibuf->y /= 2;
 }
 
-/*
-load_image handles reading the image from disk or from the packedfile.
-*/
-
-void load_image(Image * ima, int flags, char *relabase, int framenum)
-{
-       char name[FILE_MAXDIR + FILE_MAXFILE];
-
-       if (ima->ibuf == NULL) {
-
-               // is there a PackedFile with this image ?;
-               if (ima->packedfile) {
-                       ima->ibuf = IMB_ibImageFromMemory((int *) ima->packedfile->data, ima->packedfile->size, flags);
-               } else {
-                       strcpy(name, ima->name);
-                       BLI_convertstringcode(name, relabase, framenum);
-
-                       ima->ibuf = IMB_loadiffname(name , flags);
-               }
-               // check if the image is a font image...
-               // printf("Checking for font\n");
-
-               if (ima->ibuf) {
-                       detectBitmapFont(ima->ibuf);
-               }
-       }
-}
 
 void ima_ibuf_is_nul(Tex *tex)
 {
@@ -494,39 +360,37 @@ void ima_ibuf_is_nul(Tex *tex)
        Image *ima;
        int a, fra, dur;
        char str[FILE_MAXDIR+FILE_MAXFILE], *cp;
-               
+       
        ima= tex->ima;
        if(ima==0) return;
-
-       waitcursor(1);
-               
+       
        strcpy(str, ima->name);
        BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
        
        if(tex->imaflag & TEX_STD_FIELD) de_interlacefunc= de_interlace_st;
        else de_interlacefunc= de_interlace_ng;
-
-       if(tex->imaflag & TEX_ANIM5) {
        
+       if(tex->imaflag & TEX_ANIM5) {
+               
                if(ima->anim==0) ima->anim = openanim(str, IB_cmap | IB_rect);
                if (ima->anim) {
                        dur = IMB_anim_get_duration(ima->anim);
                        
                        ima->lastquality= R.osa;
                        fra= ima->lastframe-1;
-
+                       
                        if(fra<0) fra = 0;
                        if(fra>(dur-1)) fra= dur-1;
                        ima->ibuf = IMB_anim_absolute(ima->anim, fra);
-
+                       
                        /* patch for textbutton with name ima (B_NAMEIMA) */
                        if(ima->ibuf) {
                                strcpy(ima->ibuf->name, ima->name);
                                if (tex->imaflag & TEX_FIELDS) de_interlacefunc(ima->ibuf);
                        }
                }
-               else error("Not an anim");
-
+               else printf("Not an anim");
+               
        } else {
                // create a packedfile for this image when autopack is on
                // for performance (IMB_loadiffname uses mmap) we don't do this by default
@@ -535,7 +399,7 @@ void ima_ibuf_is_nul(Tex *tex)
                }
                
                load_image(ima, IB_rect, G.sce, G.scene->r.cfra);
-
+               
                if (tex->imaflag & TEX_FIELDS) de_interlacefunc(ima->ibuf);
                
                ima->lastquality= R.osa;
@@ -549,15 +413,15 @@ void ima_ibuf_is_nul(Tex *tex)
                if(ima->ibuf->cmap) {
                        
                        if(tex->imaflag & TEX_ANIM5) {
-                       
+                               
                                if(tex->imaflag & TEX_MORKPATCH) {
-                                               /**** PATCH TO SET COLOR 2 RIGHT (neogeo..) */
+                                       /**** PATCH TO SET COLOR 2 RIGHT (neogeo..) */
                                        if(ima->ibuf->maxcol > 4) {
                                                cp= (char *)(ima->ibuf->cmap+2);
                                                cp[0]= 0x80;
                                        }
                                }
-                       
+                               
                                IMB_applycmap(ima->ibuf);
                                IMB_convert_rgba_to_abgr(ima->ibuf->x*ima->ibuf->y, ima->ibuf->rect);
                                
@@ -582,989 +446,8 @@ void ima_ibuf_is_nul(Tex *tex)
                if(ima->mipmap[a]) IMB_freeImBuf(ima->mipmap[a]);
                ima->mipmap[a]= 0;
        }
-
-       if((R.flag & R_RENDERING)==0) waitcursor(0);
        
 }
 
 
 
-/* *********** IMAGEWRAPPING ****************** */
-
-
-int imagewrap(Tex *tex, float *texvec)
-{
-       Image *ima;
-       struct ImBuf *ibuf;
-       float fx, fy, val1, val2, val3;
-       int ofs, x, y;
-       char *rect;
-
-       Tin= Ta= Tr= Tg= Tb= 0.0;
-       ima= tex->ima;
-       if(ima==0 || ima->ok== 0) {
-               return 0;
-       }
-       
-       if(ima->ibuf==0) ima_ibuf_is_nul(tex);
-
-       if (ima->ok) {
-               ibuf = ima->ibuf;
-
-               if(tex->imaflag & TEX_IMAROT) {
-                       fy= texvec[0];
-                       fx= texvec[1];
-               }
-               else {
-                       fx= texvec[0];
-                       fy= texvec[1];
-               }
-               
-               if(tex->extend == TEX_CHECKER) {
-                       int xs, ys;
-                       
-                       xs= (int)floor(fx);
-                       ys= (int)floor(fy);
-                       fx-= xs;
-                       fy-= ys;
-
-                       if( (tex->flag & TEX_CHECKER_ODD)==0) {
-                               if((xs+ys) & 1);else return 0;
-                       }
-                       if( (tex->flag & TEX_CHECKER_EVEN)==0) {
-                               if((xs+ys) & 1) return 0; 
-                       }
-                       /* scale around center, (0.5, 0.5) */
-                       if(tex->checkerdist<1.0) {
-                               fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5;
-                               fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5;
-                       }
-               }
-
-               x = (int)(fx*ibuf->x);
-               y = (int)(fy*ibuf->y);
-
-               if(tex->extend == TEX_CLIPCUBE) {
-                       if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0 || texvec[2]>1.0) {
-                               return 0;
-                       }
-               }
-               else if( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
-                       if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) {
-                               return 0;
-                       }
-               }
-               else {
-                       if(tex->extend==TEX_EXTEND) {
-                               if(x>=ibuf->x) x = ibuf->x-1;
-                               else if(x<0) x= 0;
-                       }
-                       else {
-                               x= x % ibuf->x;
-                               if(x<0) x+= ibuf->x;
-                       }
-                       if(tex->extend==TEX_EXTEND) {
-                               if(y>=ibuf->y) y = ibuf->y-1;
-                               else if(y<0) y= 0;
-                       }
-                       else {
-                               y= y % ibuf->y;
-                               if(y<0) y+= ibuf->y;
-                       }
-               }
-               
-               /* warning, no return before setting back! */
-               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
-                       ibuf->rect+= (ibuf->x*ibuf->y);
-               }
-
-               ofs = y * ibuf->x + x;
-               rect = (char *)( ibuf->rect+ ofs);
-
-               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
-                       ibuf->rect-= (ibuf->x*ibuf->y);
-               }
-
-               Talpha= 0;
-               if(tex->imaflag & TEX_USEALPHA) {
-                       if(tex->imaflag & TEX_CALCALPHA);
-                       else Talpha= 1;
-               }
-
-               Tr = ((float)rect[0])/255.0f;
-               Tg = ((float)rect[1])/255.0f;
-               Tb = ((float)rect[2])/255.0f;
-               
-               if(tex->nor) {
-                       if(tex->imaflag & TEX_NORMALMAP) {
-                               tex->nor[0]= 0.5-Tr;
-                               tex->nor[1]= 0.5-Tg;
-                               tex->nor[2]= -Tb;
-                       }
-                       else {
-                               /* bump: take three samples */
-                               val1= Tr+Tg+Tb;
-
-                               if(x<ibuf->x-1) {
-                                       rect+=4;
-                                       val2= ((float)(rect[0]+rect[1]+rect[2]))/255.0f;
-                                       rect-=4;
-                               }
-                               else val2= val1;
-
-                               if(y<ibuf->y-1) {
-                                       rect+= 4*ibuf->x;
-                                       val3= ((float)(rect[0]+rect[1]+rect[2]))/255.0f;
-                               }
-                               else val3= val1;
-
-                               /* do not mix up x and y here! */
-                               tex->nor[0]= (val1-val2);
-                               tex->nor[1]= (val1-val3);
-                       }
-               }
-
-               BRICONRGB;
-
-               if(Talpha) Ta= Tin= ((float)rect[3])/255.0f;
-               else if(tex->imaflag & TEX_CALCALPHA) {
-                       Ta= Tin= MAX3(Tr, Tg, Tb);
-               }
-               else Ta= Tin= 1.0;
-               
-               if(tex->flag & TEX_NEGALPHA) Ta= 1.0f-Ta;
-
-       }
-
-       if(tex->nor) return 3;
-       else return 1;
-}
-
-void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
-/*  rctf *stack; */
-/*  short *count; */
-/*  float x1, x2; */
-{
-       rctf *rf, *newrct;
-       short a;
-
-       a= *count;
-       rf= stack;
-       for(;a>0;a--) {
-               if(rf->xmin<x1) {
-                       if(rf->xmax<x1) {
-                               rf->xmin+= (x2-x1);
-                               rf->xmax+= (x2-x1);
-                       }
-                       else {
-                               if(rf->xmax>x2) rf->xmax= x2;
-                               newrct= stack+ *count;
-                               (*count)++;
-
-                               newrct->xmax= x2;
-                               newrct->xmin= rf->xmin+(x2-x1);
-                               newrct->ymin= rf->ymin;
-                               newrct->ymax= rf->ymax;
-                               
-                               if(newrct->xmin==newrct->xmax) (*count)--;
-                               
-                               rf->xmin= x1;
-                       }
-               }
-               else if(rf->xmax>x2) {
-                       if(rf->xmin>x2) {
-                               rf->xmin-= (x2-x1);
-                               rf->xmax-= (x2-x1);
-                       }
-                       else {
-                               if(rf->xmin<x1) rf->xmin= x1;
-                               newrct= stack+ *count;
-                               (*count)++;
-
-                               newrct->xmin= x1;
-                               newrct->xmax= rf->xmax-(x2-x1);
-                               newrct->ymin= rf->ymin;
-                               newrct->ymax= rf->ymax;
-
-                               if(newrct->xmin==newrct->xmax) (*count)--;
-
-                               rf->xmax= x2;
-                       }
-               }
-               rf++;
-       }
-
-}
-
-void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
-/*  rctf *stack; */
-/*  short *count; */
-/*  float y1, y2; */
-{
-       rctf *rf, *newrct;
-       short a;
-
-       a= *count;
-       rf= stack;
-       for(;a>0;a--) {
-               if(rf->ymin<y1) {
-                       if(rf->ymax<y1) {
-                               rf->ymin+= (y2-y1);
-                               rf->ymax+= (y2-y1);
-                       }
-                       else {
-                               if(rf->ymax>y2) rf->ymax= y2;
-                               newrct= stack+ *count;
-                               (*count)++;
-
-                               newrct->ymax= y2;
-                               newrct->ymin= rf->ymin+(y2-y1);
-                               newrct->xmin= rf->xmin;
-                               newrct->xmax= rf->xmax;
-
-                               if(newrct->ymin==newrct->ymax) (*count)--;
-
-                               rf->ymin= y1;
-                       }
-               }
-               else if(rf->ymax>y2) {
-                       if(rf->ymin>y2) {
-                               rf->ymin-= (y2-y1);
-                               rf->ymax-= (y2-y1);
-                       }
-                       else {
-                               if(rf->ymin<y1) rf->ymin= y1;
-                               newrct= stack+ *count;
-                               (*count)++;
-
-                               newrct->ymin= y1;
-                               newrct->ymax= rf->ymax-(y2-y1);
-                               newrct->xmin= rf->xmin;
-                               newrct->xmax= rf->xmax;
-
-                               if(newrct->ymin==newrct->ymax) (*count)--;
-
-                               rf->ymax= y2;
-                       }
-               }
-               rf++;
-       }
-
-}
-
-
-
-float square_rctf(rctf *rf)
-/*  rctf *rf; */
-{
-       float x, y;
-
-       x= rf->xmax- rf->xmin;
-       y= rf->ymax- rf->ymin;
-       return (x*y);
-}
-
-float clipx_rctf(rctf *rf, float x1, float x2)
-/*  rctf *rf; */
-/*  float x1, x2; */
-{
-       float size;
-
-       size= rf->xmax - rf->xmin;
-
-       if(rf->xmin<x1) {
-               rf->xmin= x1;
-       }
-       if(rf->xmax>x2) {
-               rf->xmax= x2;
-       }
-       if(rf->xmin > rf->xmax) {
-               rf->xmin = rf->xmax;
-               return 0.0;
-       }
-       else if(size!=0.0) {
-               return (rf->xmax - rf->xmin)/size;
-       }
-       return 1.0;
-}
-
-float clipy_rctf(rctf *rf, float y1, float y2)
-/*  rctf *rf; */
-/*  float y1, y2; */
-{
-       float size;
-
-       size= rf->ymax - rf->ymin;
-/* PRINT(f, size); */
-       if(rf->ymin<y1) {
-               rf->ymin= y1;
-       }
-       if(rf->ymax>y2) {
-               rf->ymax= y2;
-       }
-/* PRINT(f, size); */
-       if(rf->ymin > rf->ymax) {
-               rf->ymin = rf->ymax;
-               return 0.0;
-       }
-       else if(size!=0.0) {
-               return (rf->ymax - rf->ymin)/size;
-       }
-       return 1.0;
-
-}
-
-void boxsampleclip(struct ImBuf *ibuf, rctf *rf, float *rcol,
-                                  float *gcol, float *bcol, float *acol)       /* return color 0.0-1.0 */
-/*  struct ImBuf *ibuf; */
-/*  rctf *rf; */
-/*  float *rcol, *gcol, *bcol, *acol; */
-{
-       /* sample box, is clipped already, and minx etc. have been set at ibuf size.
-       Enlarge with antialiased edges of the pixels */
-
-       float muly,mulx,div;
-       int ofs;
-       int x, y, startx, endx, starty, endy;
-       char *rect;
-
-       startx= (int)floor(rf->xmin);
-       endx= (int)floor(rf->xmax);
-       starty= (int)floor(rf->ymin);
-       endy= (int)floor(rf->ymax);
-
-       if(startx < 0) startx= 0;
-       if(starty < 0) starty= 0;
-       if(endx>=ibuf->x) endx= ibuf->x-1;
-       if(endy>=ibuf->y) endy= ibuf->y-1;
-
-       if(starty==endy && startx==endx) {
-
-               ofs = starty*ibuf->x + startx;
-               rect = (char *)(ibuf->rect +ofs);
-               *rcol= ((float)rect[0])/255.0f;
-               *gcol= ((float)rect[1])/255.0f;
-               *bcol= ((float)rect[2])/255.0f;
-                       /* alpha is global, has been set in function imagewraposa() */
-               if(Talpha) {
-                       *acol= ((float)rect[3])/255.0f;
-               }
-       }
-       else {
-               div= *rcol= *gcol= *bcol= *acol= 0.0;
-               for(y=starty;y<=endy;y++) {
-                       ofs = y*ibuf->x +startx;
-                       rect = (char *)(ibuf->rect+ofs);
-
-                       muly= 1.0;
-
-                       if(starty==endy);
-                       else {
-                               if(y==starty) muly= 1.0f-(rf->ymin - y);
-                               if(y==endy) muly= (rf->ymax - y);
-                       }
-                       if(startx==endx) {
-                               mulx= muly;
-                               if(Talpha) *acol+= mulx*rect[3];
-                               *rcol+= mulx*rect[0];
-                               *gcol+= mulx*rect[1];
-                               *bcol+= mulx*rect[2];
-                               div+= mulx;
-                       }
-                       else {
-                               for(x=startx;x<=endx;x++) {
-                                       mulx= muly;
-                                       if(x==startx) mulx*= 1.0f-(rf->xmin - x);
-                                       if(x==endx) mulx*= (rf->xmax - x);
-
-                                       if(mulx==1.0) {
-                                               if(Talpha) *acol+= rect[3];
-                                               *rcol+= rect[0];
-                                               *gcol+= rect[1];
-                                               *bcol+= rect[2];
-                                               div+= 1.0;
-                                       }
-                                       else {
-                                               if(Talpha) *acol+= mulx*rect[3];
-                                               *rcol+= mulx*rect[0];
-                                               *gcol+= mulx*rect[1];
-                                               *bcol+= mulx*rect[2];
-                                               div+= mulx;
-                                       }
-                                       rect+=4;
-                               }
-                       }
-               }
-               if(div!=0.0) {
-                       div*= 255.0;
-       
-                       *bcol/= div;
-                       *gcol/= div;
-                       *rcol/= div;
-                       
-                       if(Talpha) *acol/= div;
-               }
-               else {
-                       *rcol= *gcol= *bcol= *acol= 0.0;
-               }
-       }
-}
-
-void boxsample(struct ImBuf *ibuf,
-                          float minx, float miny, float maxx, float maxy,
-                          float *rcol, float *gcol, float *bcol, float *acol)  /* return color 0.0-1.0 */
-/*  struct ImBuf *ibuf; */
-/*  float minx, miny, maxx, maxy; */
-/*  float *rcol, *gcol, *bcol, *acol; */
-{
-       /* Sample box, performs clip. minx etc are in range 0.0 - 1.0 .
-     * Enlarge with antialiased edges of pixels.
-     * If global variable 'imaprepeat' has been set, the
-     *  clipped-away parts are sampled as well.
-     */
-       rctf *rf, stack[8];
-       float opp, tot, r, g, b, a, alphaclip= 1.0;
-       short count=1;
-
-       rf= stack;
-       rf->xmin= minx*(ibuf->x);
-       rf->xmax= maxx*(ibuf->x);
-       rf->ymin= miny*(ibuf->y);
-       rf->ymax= maxy*(ibuf->y);
-
-       if(imapextend);
-       else if(imaprepeat) clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
-       else {
-               alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x));
-
-               if(alphaclip<=0.0) {
-                       *rcol= *bcol= *gcol= *acol= 0.0;
-                       return;
-               }
-       }
-
-       if(imapextend);
-       else if(imaprepeat) clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
-       else {
-               alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y));
-
-               if(alphaclip<=0.0) {
-                       *rcol= *bcol= *gcol= *acol= 0.0;
-                       return;
-               }
-       }
-
-       if(count>1) {
-               tot= *rcol= *bcol= *gcol= *acol= 0.0;
-               while(count--) {
-                       boxsampleclip(ibuf, rf, &r, &g, &b, &a);
-                       
-                       opp= square_rctf(rf);
-                       tot+= opp;
-
-                       *rcol+= opp*r;
-                       *gcol+= opp*g;
-                       *bcol+= opp*b;
-                       if(Talpha) *acol+= opp*a;
-                       rf++;
-               }
-               if(tot!= 0.0) {
-                       *rcol/= tot;
-                       *gcol/= tot;
-                       *bcol/= tot;
-                       if(Talpha) *acol/= tot;
-               }
-       }
-       else {
-               boxsampleclip(ibuf, rf, rcol, gcol, bcol, acol);
-       }
-
-       if(Talpha==0) *acol= 1.0;
-       
-       if(alphaclip!=1.0) {
-               /* this is for laetr investigation, premul or not? */
-               /* *rcol*= alphaclip; */
-               /* *gcol*= alphaclip; */
-               /* *bcol*= alphaclip; */
-               *acol*= alphaclip;
-       }
-}      
-
-void filtersample(struct ImBuf *ibuf,
-                                 float fx, float fy,
-                                 float *rcol, float *gcol, float *bcol, float *acol)
-       /* return color 0.0-1.0 */
-/*  struct ImBuf *ibuf; */                                                                             /* fx en fy tussen 0.0 en 1.0 */
-/*  float fx, fy; */
-/*  float *rcol, *gcol, *bcol, *acol; */
-{
-       /* with weighted filter 3x3
-     * left or right collumn is always 0
-     * upper or lower row is awlays 0
-     */
-
-       int fac, fac1, fac2, fracx, fracy, filt[4];
-       int ix, iy, x4;
-       unsigned int r=0, g=0, b=0, a=0;
-       char *rowcol, *rfilt[4];
-
-       ix= (int)( 256.0*fx );
-       fracx= (ix & 255);
-       ix= (ix>>8);
-       iy= (int)( 256.0*fy );
-       fracy= (iy & 255);
-       iy= (iy>>8);
-       
-       if(ix>=ibuf->x) ix= ibuf->x-1;
-       if(iy>=ibuf->y) iy= ibuf->y-1;
-       
-       rowcol= (char *)(ibuf->rect+ iy*ibuf->x +ix);
-
-       rfilt[0]= rfilt[1]= rfilt[2]= rfilt[3]= rowcol;
-       x4= 4*ibuf->x;
-
-       if(fracx<128) {
-               if(ix>0) { 
-                       rfilt[0]-= 4; 
-                       rfilt[2]-=4; 
-               }
-               else if(imaprepeat) { 
-                       rfilt[0]+= x4-4; 
-                       rfilt[2]+= x4-4; 
-               }
-
-               if(fracy<128) {
-                       /* case left-under */
-                       fac1= 128+fracy;
-                       fac2= 128-fracy;
-
-                       if(iy>0) { 
-                               rfilt[3]-= x4; 
-                               rfilt[2]-= x4; 
-                       }
-                       else if(imaprepeat) {
-                               fac= x4*(ibuf->y-1) ;
-                               rfilt[3]+= fac; 
-                               rfilt[2]+= fac;
-                       }
-               }
-               else {
-                       /* case left-upper */
-                       fac2= 384-fracy;
-                       fac1= fracy-128;
-
-                       if(iy<ibuf->y-1) { 
-                               rfilt[1]+= x4; 
-                               rfilt[0]+= x4; 
-                       }
-                       else if(imaprepeat) {
-                               fac= x4*(ibuf->y-1) ;
-                               rfilt[1]-= fac; 
-                               rfilt[0]-= fac;
-                       }
-               }
-
-               filt[1]=filt[3]= 128+ fracx;
-               filt[0]=filt[2]= 128- fracx;
-               filt[0]*= fac1; 
-               filt[1]*= fac1;
-               filt[2]*= fac2; 
-               filt[3]*= fac2;
-       }
-       else {
-               if(fracy<128) {
-                       /* case right-under */
-                       fac1= 128+fracy;
-                       fac2= 128-fracy;
-
-                       if(iy>0) { 
-                               rfilt[3]-= x4; 
-                               rfilt[2]-= x4; 
-                       }
-                       else if(imaprepeat) {
-                               fac= x4*(ibuf->y-1) ;
-                               rfilt[3]+= fac; 
-                               rfilt[2]+= fac;
-                       }
-               }
-               else {
-                       /* case right-upper */
-                       fac2= 384-fracy;
-                       fac1= fracy-128;
-
-                       if(iy<ibuf->y-1) { 
-                               rfilt[1]+= x4; 
-                               rfilt[0]+= x4; 
-                       }
-                       else if(imaprepeat) {
-                               fac= x4*(ibuf->y-1) ;
-                               rfilt[1]-= fac; 
-                               rfilt[0]-= fac;
-                       }
-               }
-               filt[0]=filt[2]= 384-fracx;
-               filt[1]=filt[3]= fracx-128;
-               filt[0]*= fac1; 
-               filt[1]*= fac1;
-               filt[2]*= fac2; 
-               filt[3]*= fac2;
-
-               if(ix<ibuf->x-1) { 
-                       rfilt[1]+= 4; 
-                       rfilt[3]+=4; 
-               }
-               else if(imaprepeat) { 
-                       rfilt[1]-= x4-4; 
-                       rfilt[3]-= x4-4; 
-               }
-       }
-
-       for(fac=3; fac>=0; fac--) {
-               rowcol= rfilt[fac];
-               r+= filt[fac]*rowcol[0];
-               g+= filt[fac]*rowcol[1];
-               b+= filt[fac]*rowcol[2];
-               if(Talpha) a+= filt[fac]*rowcol[3];             /* alpha is global */
-       }
-       *rcol= ((float)r)/16777216.0f;
-       *gcol= ((float)g)/16777216.0f;
-       *bcol= ((float)b)/16777216.0f;
-       if(Talpha) *acol= ((float)a)/16777216.0f;
-       
-}
-
-
-int imagewraposa(Tex *tex, float *texvec, float *dxt, float *dyt)
-{
-       struct Image *ima;
-       struct ImBuf *ibuf, *previbuf;
-       float fx, fy, minx, maxx, miny, maxy, dx, dy, fac1, fac2, fac3, fac4;
-       float maxd, pixsize, val1, val2, val3;
-       int curmap;
-
-#ifdef IMAGE_C_ARG_CHECK
-       if (!tex) {
-               printf("imagewraposa: null pointer to texture\n");
-       }
-#endif
-       
-       ima= tex->ima;
-#ifdef IMAGE_C_ARG_CHECK
-       if (!ima) {
-               printf("imagewraposa: null pointer to image\n");
-       }
-#endif
-
-       Tin= Ta= Tr= Tg= Tb= 0.0;
-
-       if(ima==0 || ima->ok== 0) {
-               return 0;
-       }
-       
-       if(ima->ibuf==0) ima_ibuf_is_nul(tex);
-
-       if (ima->ok) {
-       
-               if(tex->imaflag & TEX_MIPMAP) {
-                       if(ima->mipmap[0]==0) makemipmap(ima);
-               }
-       
-               ibuf = ima->ibuf;
-               
-               Talpha= 0;
-               if(tex->imaflag & TEX_USEALPHA) {
-                       if(tex->imaflag & TEX_CALCALPHA);
-                       else Talpha= 1;
-               }
-               
-               if(tex->imaflag & TEX_IMAROT) {
-                       fy= texvec[0];
-                       fx= texvec[1];
-               }
-               else {
-                       fx= texvec[0];
-                       fy= texvec[1];
-               }
-               
-               if(ibuf->flags & IB_fields) {
-                       if(R.r.mode & R_FIELDS) {                       /* field render */
-                               if(R.flag & R_SEC_FIELD) {              /* correction for 2nd field */
-                                       /* fac1= 0.5/( (float)ibuf->y ); */
-                                       /* fy-= fac1; */
-                               }
-                               else {                          /* first field */
-                                       fac1= 0.5f/( (float)ibuf->y );
-                                       fy+= fac1;
-                               }
-                       }
-               }
-               
-               /* pixel coordinates */
-
-               minx= MIN3(dxt[0],dyt[0],dxt[0]+dyt[0] );
-               maxx= MAX3(dxt[0],dyt[0],dxt[0]+dyt[0] );
-               miny= MIN3(dxt[1],dyt[1],dxt[1]+dyt[1] );
-               maxy= MAX3(dxt[1],dyt[1],dxt[1]+dyt[1] );
-
-               /* tex_sharper has been removed */
-
-               minx= tex->filtersize*(maxx-minx)/2.0f;
-               miny= tex->filtersize*(maxy-miny)/2.0f;
-               
-               if(tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny);
-               
-               if(minx>0.25) minx= 0.25;
-               else if(minx<0.00001f) minx= 0.00001f;  /* side faces of unit-cube */
-               if(miny>0.25) miny= 0.25;
-               else if(miny<0.00001f) miny= 0.00001f;
-
-               
-               /* repeat and clip */
-               
-               /* watch it: imaprepeat is global value (see boxsample) */
-               imaprepeat= (tex->extend==TEX_REPEAT);
-               imapextend= (tex->extend==TEX_EXTEND);
-
-               if(tex->extend == TEX_CHECKER) {
-                       int xs, ys, xs1, ys1, xs2, ys2, boundary;
-                       
-                       xs= (int)floor(fx);
-                       ys= (int)floor(fy);
-                       
-                       // both checkers available, no boundary exceptions, checkerdist will eat aliasing
-                       if( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) {
-                               fx-= xs;
-                               fy-= ys;
-                       }
-                       else {
-                               
-                               xs1= (int)floor(fx-minx);
-                               ys1= (int)floor(fy-miny);
-                               xs2= (int)floor(fx+minx);
-                               ys2= (int)floor(fy+miny);
-                               boundary= (xs1!=xs2) || (ys1!=ys2);
-       
-                               if(boundary==0) {
-                                       if( (tex->flag & TEX_CHECKER_ODD)==0) {
-                                               if((xs+ys) & 1); 
-                                               else return 0;
-                                       }
-                                       if( (tex->flag & TEX_CHECKER_EVEN)==0) {
-                                               if((xs+ys) & 1) return 0;
-                                       }
-                                       fx-= xs;
-                                       fy-= ys;
-                               }
-                               else {
-                                       if(tex->flag & TEX_CHECKER_ODD) {
-                                               if((xs1+ys) & 1) fx-= xs2;
-                                               else fx-= xs1;
-                                               
-                                               if((ys1+xs) & 1) fy-= ys2;
-                                               else fy-= ys1;
-                                       }
-                                       if(tex->flag & TEX_CHECKER_EVEN) {
-                                               if((xs1+ys) & 1) fx-= xs1;
-                                               else fx-= xs2;
-                                               
-                                               if((ys1+xs) & 1) fy-= ys1;
-                                               else fy-= ys2;
-                                       }
-                               }
-                       }
-
-                       /* scale around center, (0.5, 0.5) */
-                       if(tex->checkerdist<1.0) {
-                               fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5;
-                               fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5;
-                               minx/= (1.0-tex->checkerdist);
-                               miny/= (1.0-tex->checkerdist);
-                       }
-               }
-
-               if(tex->extend == TEX_CLIPCUBE) {
-                       if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0 || texvec[2]<-1.0 || texvec[2]>1.0) {
-                               return 0;
-                       }
-               }
-               else if(tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
-                       if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0) {
-                               return 0;
-                       }
-               }
-               else {
-                       if(tex->extend==TEX_EXTEND) {
-                               if(fx>1.0) fx = 1.0;
-                               else if(fx<0.0) fx= 0.0;
-                       }
-                       else {
-                               if(fx>1.0) fx -= (int)(fx);
-                               else if(fx<0.0) fx+= 1-(int)(fx);
-                       }
-                       
-                       if(tex->extend==TEX_EXTEND) {
-                               if(fy>1.0) fy = 1.0;
-                               else if(fy<0.0) fy= 0.0;
-                       }
-                       else {
-                               if(fy>1.0) fy -= (int)(fy);
-                               else if(fy<0.0) fy+= 1-(int)(fy);
-                       }
-               }
-       
-               /* warning no return! */
-               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
-                       ibuf->rect+= (ibuf->x*ibuf->y);
-               }
-
-               /* choice:  */
-               if(tex->imaflag & TEX_MIPMAP) {
-                       
-                       dx= minx;
-                       dy= miny;
-                       maxd= MAX2(dx, dy);
-                       if(maxd>0.5) maxd= 0.5;
-
-                       pixsize = 1.0f/ (float) MIN2(ibuf->x, ibuf->y);
-                       
-                       curmap= 0;
-                       previbuf= ibuf;
-                       while(curmap<BLI_ARRAY_NELEMS(ima->mipmap) && ima->mipmap[curmap]) {
-                               if(maxd < pixsize) break;
-                               previbuf= ibuf;
-                               ibuf= ima->mipmap[curmap];
-                               pixsize= 1.0f / (float)MIN2(ibuf->x, ibuf->y); /* this used to be 1.0 */                
-                               curmap++;
-                       }
-                       
-                       if(previbuf!=ibuf || (tex->imaflag & TEX_INTERPOL)) {
-                               /* sample at least 1 pixel */
-                               if (minx < 0.5f / ima->ibuf->x) minx = 0.5f / ima->ibuf->x;
-                               if (miny < 0.5f / ima->ibuf->y) miny = 0.5f / ima->ibuf->y;
-                       }
-                       
-                       if(tex->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
-                               /* a bit extra filter */
-                               minx*= 1.35f;
-                               miny*= 1.35f;
-                               
-                               boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, &Tr, &Tg, &Tb, &Ta);
-                               val1= Tr+Tg+Tb;
-                               boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &fac1, &fac2, &fac3, &fac4);
-                               val2= fac1+fac2+fac3;
-                               boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &fac1, &fac2, &fac3, &fac4);
-                               val3= fac1+fac2+fac3;
-       
-                               if(previbuf!=ibuf) {  /* interpolate */
-                                       
-                                       boxsample(previbuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, &fac1, &fac2, &fac3, &fac4);
-                                       
-                                       /* calc rgb */
-                                       dx= 2.0f*(pixsize-maxd)/pixsize;
-                                       if(dx>=1.0f) {
-                                               Ta= fac4; Tb= fac3;
-                                               Tg= fac2; Tr= fac1;
-                                       }
-                                       else {
-                                               dy= 1.0f-dx;
-                                               Tb= dy*Tb+ dx*fac3;
-                                               Tg= dy*Tg+ dx*fac2;
-                                               Tr= dy*Tr+ dx*fac1;
-                                               if(Talpha) Ta= dy*Ta+ dx*fac4;
-                                       }
-                                       
-                                       val1= dy*val1+ dx*(fac1+fac2+fac3);
-                                       boxsample(previbuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &fac1, &fac2, &fac3, &fac4);
-                                       val2= dy*val2+ dx*(fac1+fac2+fac3);
-                                       boxsample(previbuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &fac1, &fac2, &fac3, &fac4);
-                                       val3= dy*val3+ dx*(fac1+fac2+fac3);
-                               }
-
-                               /* don't switch x or y! */
-                               tex->nor[0]= (val1-val2);
-                               tex->nor[1]= (val1-val3);
-                       }
-                       else {
-                               maxx= fx+minx;
-                               minx= fx-minx;
-                               maxy= fy+miny;
-                               miny= fy-miny;
-       
-                               boxsample(ibuf, minx, miny, maxx, maxy, &Tr, &Tg, &Tb, &Ta);
-       
-                               if(previbuf!=ibuf) {  /* interpolate */
-                                       boxsample(previbuf, minx, miny, maxx, maxy, &fac1, &fac2, &fac3, &fac4);
-                                       
-                                       fx= 2.0f*(pixsize-maxd)/pixsize;
-                                       
-                                       if(fx>=1.0) {
-                                               Ta= fac4; Tb= fac3;
-                                               Tg= fac2; Tr= fac1;
-                                       } else {
-                                               fy= 1.0f-fx;
-                                               Tb= fy*Tb+ fx*fac3;
-                                               Tg= fy*Tg+ fx*fac2;
-                                               Tr= fy*Tr+ fx*fac1;
-                                               if(Talpha) Ta= fy*Ta+ fx*fac4;
-                                       }
-                               }
-                       }
-               }
-               else {
-                       if((tex->imaflag & TEX_INTERPOL)) {
-                               /* sample 1 pixel minimum */
-                               if (minx < 0.5f / ima->ibuf->x) minx = 0.5f / ima->ibuf->x;
-                               if (miny < 0.5f / ima->ibuf->y) miny = 0.5f / ima->ibuf->y;
-                       }
-
-                       if(tex->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
-                               
-                               /* a bit extra filter */
-                               minx*= 1.35f;
-                               miny*= 1.35f;
-                               
-                               boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, &Tr, &Tg, &Tb, &Ta);
-                               val1= Tr+Tg+Tb;
-
-                               boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &fac1, &fac2, &fac3, &fac4);
-                               val2= fac1+fac2+fac3;
-                               
-                               boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+miny, fy+2.0f*miny, &fac1, &fac2, &fac3, &fac4);
-                               val3= fac1+fac2+fac3;
-
-                               /* don't switch x or y! */
-                               tex->nor[0]= (val1-val2);
-                               tex->nor[1]= (val1-val3);
-                       }
-                       else {
-                               boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, &Tr, &Tg, &Tb, &Ta);
-                       }
-               }
-               
-               BRICONRGB;
-               
-               if(tex->imaflag & TEX_CALCALPHA) {
-                       Ta= Tin= Ta*MAX3(Tr, Tg, Tb);
-               }
-               else Tin= Ta;
-               if(tex->flag & TEX_NEGALPHA) Ta= 1.0f-Ta;
-               
-               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
-                       ibuf->rect-= (ibuf->x*ibuf->y);
-               }
-
-               if(tex->nor && (tex->imaflag & TEX_NORMALMAP)) {
-                       tex->nor[0]= 0.5-Tr;
-                       tex->nor[1]= 0.5-Tg;
-                       tex->nor[2]= -Tb;
-               }
-       }
-       else {
-               Tin= 0.0f;
-               return 0;
-       }
-       
-       if(tex->nor) return 3;
-       else return 1;
-}
-
index 71e19c040c50d27c05e4a8a3c083bd6fb84a12f8..f89b36a50cf70e01e98283fbbb001faf6864a15c 100644 (file)
@@ -59,9 +59,7 @@
 
 #include "BPY_extern.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "render.h"
 
 void free_material(Material *ma)
 {
@@ -70,9 +68,6 @@ void free_material(Material *ma)
 
        BPY_free_scriptlink(&ma->scriptlink);
        
-       if(ma->ren) MEM_freeN(ma->ren);
-       ma->ren= NULL;
-       
        for(a=0; a<MAX_MTEX; a++) {
                mtex= ma->mtex[a];
                if(mtex && mtex->tex) mtex->tex->id.us--;
@@ -543,15 +538,9 @@ void init_render_material(Material *ma)
        MTex *mtex;
        int a, needuv=0;
        
-       if(ma->ren) return;
-
        if(ma->flarec==0) ma->flarec= 1;
 
-       ma->ren= MEM_mallocN(sizeof(Material), "initrendermaterial");
-       memcpy(ma->ren, ma, sizeof(Material));
-       
        /* add all texcoflags from mtex */
-       ma= ma->ren;
        ma->texco= 0;
        ma->mapto= 0;
        for(a=0; a<MAX_MTEX; a++) {
@@ -584,9 +573,6 @@ void init_render_material(Material *ma)
        }
        if(needuv) ma->texco |= NEED_UV;
        
-       // optimize, render only checks for ray_mirror value */
-       if((ma->mode & MA_RAYMIRROR)==0) ma->ray_mirror= 0.0;
-       
        // since the raytracer doesnt recalc O structs for each ray, we have to preset them all
        if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP|MA_SHADOW_TRA)) { 
                ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM;
@@ -613,10 +599,7 @@ void init_render_materials()
 
 void end_render_material(Material *ma)
 {
-       
-       if(ma->ren) MEM_freeN(ma->ren);
-       ma->ren= 0;
-
+       /* XXXX obsolete? check! */
        if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
                if( !(ma->mode & MA_HALO) ) {
                        ma->r= ma->g= ma->b= 1.0;
@@ -748,8 +731,6 @@ void delete_material_index()
                }
                obt= obt->id.next;
        }
-       allqueue(REDRAWBUTSMAT, 0);
-       
 
        /* check indices from mesh */
 
index 7a751f2d720807593d7b079e878f85bce1e752d7..dbca2b6ec4f6e352acc78e81ae5841f46b418250 100644 (file)
@@ -169,16 +169,15 @@ Scene *add_scene(char *name)
        sce->r.framelen= 1.0;
        sce->r.frs_sec= 25;
 
+       sce->r.postgamma= 1.0;
+       sce->r.posthue= 1.0;
+       sce->r.postmul= 1.0;
+       
        sce->r.xplay= 640;
        sce->r.yplay= 480;
        sce->r.freqplay= 60;
        sce->r.depth= 32;
 
-       if (sce->r.avicodecdata) {
-printf("this is not good\n");
-       }
-//     sce->r.imtype= R_TARGA;
-
        sce->r.stereomode = 1;  // no stereo
 
        strcpy(sce->r.backbuf, "//backbuf");
index e25a8a7f13cc80fff604967625a471f9feabb569..c5f26eeb19c19b02f13060afd9f0f30a2c27e0b6 100644 (file)
@@ -65,7 +65,6 @@
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 
-#include "BKE_osa_types.h"
 #include "BKE_plugin_types.h"
 
 #include "BKE_bad_level_calls.h"
@@ -82,8 +81,6 @@
 #include "BKE_ipo.h"
 
 
-
-
 /* ------------------------------------------------------------------------- */
 
 /* All support for plugin textures: */
@@ -241,14 +238,11 @@ ColorBand *add_colorband()
 
 int do_colorband(ColorBand *coba, float in, float out[4])
 {
-       /* These vars form the texture channel, in render/intern/texture.c */
-       extern int Talpha;
        CBData *cbd1, *cbd2, *cbd0, *cbd3;
        float fac, mfac, t[4];
        int a;
        
        if(coba->tot==0) return 0;
-       Talpha= 1;
        
        cbd1= coba->data;
        if(coba->tot==1) {
index 77081f992469e28375f14753ae81daf869a1b3e6..abb5a2757dc58c569bcef05c2607d3d499d223a7 100644 (file)
@@ -783,6 +783,10 @@ Vec2Addf(
        float *v2
 );
 
+void tubemap(float x, float y, float z, float *u, float *v);
+void spheremap(float x, float y, float z, float *u, float *v);
+                         
+                         
 #ifdef __cplusplus
 }
 #endif
index f73005dcd9b2c48216d2f165359b9ade043951c4..c4dd5de3a0e39772aafab0edcfaa88105b319d7b 100644 (file)
@@ -2492,3 +2492,38 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b)
        *b= (float)(((col)>>16)&0xFF);
        *b /= 255.0f;
 }
+
+
+/* *************** PROJECTIONS ******************* */
+
+void tubemap(float x, float y, float z, float *u, float *v)
+{
+       float len;
+       
+       *v = (z + 1.0) / 2.0;
+       
+       len= sqrt(x*x+y*y);
+       if(len>0) {
+               *u = (1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void spheremap(float x, float y, float z, float *u, float *v)
+{
+       float len;
+       
+       len= sqrt(x*x+y*y+z*z);
+       if(len>0.0) {
+               
+               if(x==0.0 && y==0.0) *u= 0.0;   /* othwise domain error */
+               else *u = (1.0 - atan2(x,y)/M_PI )/2.0;
+               
+               z/=len;
+               *v = 1.0- saacos(z)/M_PI;
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
index 5e4bdd3ed7c3802dd0918601eff67f8d5e550cd3..9efdb1f90f38f6f60959dd6d402f49a32e29cab7 100644 (file)
 
 #include "BKE_bad_level_calls.h" // for reopen_text build_seqar (from WHILE_SEQ) open_plugin_seq set_rects_butspace check_imasel_copy
 
+#include "BKE_armature.h"      //      for precalc_bonelist_irestmats
+#include "BKE_action.h"
 #include "BKE_constraint.h"
-#include "BKE_utildefines.h" // SWITCH_INT WHILE_SEQ END_SEQ DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
-#include "BKE_main.h" // for Main
+#include "BKE_curve.h"
+#include "BKE_effect.h" // for give_parteff
 #include "BKE_global.h" // for G
 #include "BKE_property.h" // for get_property
 #include "BKE_library.h" // for wich_libbase
-#include "BKE_texture.h" // for open_plugin_tex
-#include "BKE_effect.h" // for give_parteff
-#include "BKE_sca.h" // for init_actuator
+#include "BKE_main.h" // for Main
 #include "BKE_mesh.h" // for ME_ defines (patching)
-#include "BKE_armature.h"      //      for precalc_bonelist_irestmats
-#include "BKE_action.h"
 #include "BKE_object.h"
+#include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
+#include "BKE_texture.h" // for open_plugin_tex
+#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
 
 #include "BIF_butspace.h" // for do_versions, patching event codes
 
 #include "BLO_readfile.h"
 #include "BLO_undofile.h"
+#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
+
 #include "readfile.h"
 
 #include "genfile.h"
 
-#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
-
 #include "mydevice.h"
+#include "blendef.h"
 
 /*
  Remark: still a weak point is the newadress() function, that doesnt solve reading from
@@ -2012,7 +2014,6 @@ static void direct_link_material(FileData *fd, Material *ma)
        ma->ramp_col= newdataadr(fd, ma->ramp_col);
        ma->ramp_spec= newdataadr(fd, ma->ramp_spec);
        
-       ma->ren= NULL;  /* should not be needed, nevertheless... */
 }
 
 /* ************ READ MESH ***************** */
@@ -4594,11 +4595,24 @@ static void do_versions(Main *main)
        }
        if(main->versionfile <= 235) {
                Tex *tex= main->tex.first;
+               Scene *sce= main->scene.first;
                
                while(tex) {
                        if(tex->nabla==0.0) tex->nabla= 0.025;
                        tex= tex->id.next;
                }
+               while(sce) {
+                       sce->r.postsat= 1.0;
+                       sce= sce->id.next;
+               }
+       }
+       if(main->versionfile <= 236) {
+               Scene *sce= main->scene.first;
+               
+               while(sce) {
+                       if(sce->r.postsat==0.0) sce->r.postsat= 1.0;
+                       sce= sce->id.next;
+               }
        }
        
        /* don't forget to set version number in blender.c! */
index 7fc8ac914e41fdf4155046c19183275e5c5560a3..3232f12f13e954ac74df93cf3468baf6ee99f966 100644 (file)
@@ -144,15 +144,17 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
 #include "BLI_linklist.h"
 
 #include "BKE_action.h"
-#include "BKE_utildefines.h" // for KNOTSU KNOTSV WHILE_SEQ END_SEQ defines
 #include "BKE_bad_level_calls.h" // build_seqar (from WHILE_SEQ) free_oops error
+#include "BKE_curve.h"
 #include "BKE_constraint.h"
-#include "BKE_main.h" // G.main
 #include "BKE_global.h" // for G
-#include "BKE_screen.h" // for waitcursor
-#include "BKE_packedFile.h" // for packAll
 #include "BKE_library.h" // for  set_listbasepointers
+#include "BKE_main.h" // G.main
+#include "BKE_packedFile.h" // for packAll
+#include "BKE_screen.h" // for waitcursor
+#include "BKE_scene.h" // for do_seq
 #include "BKE_sound.h" /* ... and for samples */
+#include "BKE_utildefines.h" // for defines
 
 #include "GEN_messaging.h"
 
@@ -1494,8 +1496,8 @@ static void write_global(WriteData *wd)
 
        fg.curscreen= G.curscreen;
        fg.curscene= G.scene;
-       fg.displaymode= R.displaymode;
-       fg.winpos= R.winpos;
+       fg.displaymode= G.displaymode;
+       fg.winpos= G.winpos;
        fg.fileflags= (G.fileflags & ~G_FILE_NO_UI);    // prevent to save this, is not good convention, and feature with concerns...
        fg.globalf= G.f;
 
index facfecb0c6ed7c90d1ecc46e7b04fbaa26af7e5e..b82a1ab71335a43885328771d92032736435245d 100644 (file)
@@ -34,7 +34,6 @@
 #define BIF_MESHTOOLS_H
 
 extern void join_mesh(void);
-extern void make_sticky(void);
 
 extern void fasterdraw(void);
 extern void slowerdraw(void);
index efc13950bd66856ac63d2f19621ec03a7bb1bd17..6b607b110d615400c02512f59c204bfeecbf8ea1 100644 (file)
@@ -46,6 +46,7 @@ void BIF_do_ogl_render(struct View3D *v3d, int anim);
 void BIF_renderwin_set_for_ogl_render(void);
 void BIF_renderwin_set_custom_cursor(unsigned char mask[16][2], unsigned char bitmap[16][2]);
 
+void BIF_redraw_render_rect(void);
 void BIF_swap_render_rects(void);
 void BIF_toggle_render_display(void);
 
index 219b9cb1c7ce1d60507930742fdb371ac9085ab8..994559e6194c04f4e0a239c400bcb9631896c3df 100644 (file)
@@ -34,6 +34,7 @@
 #ifndef BSE_SEQUENCE_H
 #define BSE_SEQUENCE_H
 
+
 struct PluginSeq;
 struct StripElem;
 struct Strip;
index 1f6272342168a40c8def08a205d6f63f7f6b675b..d4d2b2eba9b5f875075f9c10f78744d0c822b702 100644 (file)
 #ifndef BLENDEF_H
 #define BLENDEF_H
 
-#ifdef WIN32
-#else
-#ifndef __BeOS
-#define O_BINARY       0
-#endif
-#endif
 
 /* **************** MAX ********************* */
 
 #define MAXFLOAT  ((float)3.40282347e+38)
 #endif
 
-#include <float.h>     
-
-
-
-
-/* **************** GENERAL ********************* */
-
-#define VECCOPY(v1,v2)                 {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
-#define QUATCOPY(v1,v2)        {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
-
-#define VECADD(v1,v2,v3)       {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
-#define VECSUB(v1,v2,v3)       {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
+/* also fill in structs itself, dna cannot handle defines, duplicate with utildefines.h still */
+#ifndef FILE_MAXDIR
+#define FILE_MAXDIR                    160
+#define FILE_MAXFILE           80
+#endif
 
-#define INPR(v1, v2)           ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
-#define CLAMP(a, b, c)         if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
-#define CLAMPIS(a, b, c)       ((a)<(b) ? (b) : (a)>(c) ? (c) : (a))
-#define CLAMPTEST(a, b, c)     if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);}
 
-#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1)
+#include <float.h>     
 
-#define INIT_MINMAX(min, max) (min)[0]= (min)[1]= (min)[2]= 1.0e30; (max)[0]= (max)[1]= (max)[2]= -1.0e30;
-#define DO_MINMAX(vec, min, max) if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
-                                                         if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
-                                                         if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
-                                                         if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
-                                                         if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
-                                                         if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; \
 
-#define DO_MINMAX2(vec, min, max) if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
-                                                         if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
-                                                         if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
-                                                         if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];
 
-#define MINSIZE(val, size)     ( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val)))
 
-#define BTST(a,b)      ( ( (a) & 1<<(b) )!=0 )
-#define BCLR(a,b)      ( (a) & ~(1<<(b)) )
-#define BSET(a,b)      ( (a) | 1<<(b) )
-/* bit-row */
-#define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) )
+/* **************** GENERAL ********************* */
 
 // return values
 
 #define RET_YES (1 == 1)
 #define RET_NO (1 == 0)
 
-#define LONGCOPY(a, b, c)      {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
-
 #if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
 /* big endian */
 #define MAKE_ID2(c, d)         ( (c)<<8 | (d) )
 #define ISPOIN4(a, b, c, d, e) ( (a->b) && (a->c) && (a->d) && (a->e) )
 
 
-#define KNOTSU(nu)         ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-#define KNOTSV(nu)         ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
-
 /* psfont */
 #define FNT_PDRAW 1
 #define FNT_HAEBERLI 2
 #define B_PERCENTSUBD          0x40
 
 
-/* ***************** DISPLIST ***************** */
-
-#define DL_POLY                        0
-#define DL_SEGM                        1
-#define DL_SURF                        2
-#define DL_TRIA                        3
-#define DL_INDEX3              4
-#define DL_INDEX4              5
-#define DL_VERTCOL             6
-#define DL_VERTS               7
-#define DL_NORS                        8
-
-#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev)           \
-                                                           \
-    if( (cyclv)==0 && a==(sizev)-1) break;                 \
-    if(cyclu) {                                                    \
-       p1= sizeu*a;                                        \
-       p2= p1+ sizeu-1;                                    \
-       p3= p1+ sizeu;                                      \
-       p4= p2+ sizeu;                                      \
-       b= 0;                                               \
-    }                                                      \
-    else {                                                 \
-       p2= sizeu*a;                                        \
-       p1= p2+1;                                           \
-       p4= p2+ sizeu;                                      \
-       p3= p1+ sizeu;                                      \
-       b= 1;                                               \
-    }                                                      \
-    if( (cyclv) && a==sizev-1) {                           \
-       p3-= sizeu*sizev;                                   \
-       p4-= sizeu*sizev;                                   \
-    }
-
 /* DISPLAYMODE */
 #define R_DISPLAYVIEW  0
 #define R_DISPLAYWIN   1
 #define R_DISPLAYAUTO  2
 
-
-
-#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
-#define RCOMP  3
-#define GCOMP  2
-#define BCOMP  1
-#define ACOMP  0
-
-#else
-
-#define RCOMP  0
-#define GCOMP  1
-#define BCOMP  2
-#define ACOMP  3
-#endif
-
-#ifdef GS
-#undef GS
-#endif
-#define GS(a)  (*((short *)(a)))
-
 #endif
index 06326142c6436ce74fc2335052430a010900cbed..9bbc63f729d858c500fb3de94147843c02c3e8b4 100644 (file)
@@ -274,6 +274,7 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
 #define B_SELECTCODEC   1639
 #define B_RTCHANGED            1640
 #define B_SWITCHRENDER 1641
+#define B_FBUF_REDO            1642
 
 #ifdef __NLA
 /* *********************** */
index fa2447a12f409a20b5964700739991aee913e131..b5adabbdc1562711bce14a742f93e06235d38260 100644 (file)
@@ -93,7 +93,6 @@ typedef struct Material {
        
        struct MTex *mtex[10];
        struct Ipo *ipo;
-       struct Material *ren;
        
        /* dynamic properties */
        float friction, fh, reflect;
index 36dbd75d74197578dc3a2d92274a06f89b12ceed..04aa96c9d1fa31a2ab06f994e543e15ad0f6c371 100644 (file)
@@ -178,6 +178,8 @@ typedef struct RenderData {
         * 14: motion blur
         * 15: use unified renderer for this pic
         * 16: enable raytracing
+        * 17: gauss sampling for subpixels
+        * 18: keep float buffer after render
         */
        int mode;
 
@@ -208,9 +210,9 @@ typedef struct RenderData {
         * The gamma for the normal rendering. Used when doing
         * oversampling, to correctly blend subpixels to pixels.  */
        float gamma, gauss;
-       /** post-production settings. Don't really belong here */
-       float postmul, postgamma, postadd, postigamma;
-
+       /** post-production settings. */
+       float postmul, postgamma, postadd, postigamma, posthue, postsat;
+       
        /* Dither noise intensity */
        float dither_intensity;
        float pad_dither;
@@ -298,6 +300,8 @@ typedef struct Scene {
 #define R_UNIFIED       0x8000
 #define R_RAYTRACE      0x10000
 #define R_GAUSS        0x20000
+#define R_FBUF                 0x40000
+#define R_THREADS              0x80000
 
 /* yafray: renderer flag (not only exclusive to yafray) */
 #define R_INTERN       0
@@ -347,6 +351,7 @@ typedef struct Scene {
 #define R_LAMPHALO             8
 #define R_RENDERING            16
 #define R_ANIMRENDER   32
+#define R_REDRAW_PRV   64
 
 /* vlakren->flag (vlak = face in dutch) char!!! */
 #define R_SMOOTH               1
index 634d9e887ebd88b12099d1e11231d9e8065675de..cd6a0b8bbdbcb30cf522b4a992b5a40ed89c1e98 100644 (file)
@@ -151,7 +151,7 @@ typedef struct Tex {
        short extend, len;
        float checkerdist, nabla;
        short frames, offset, sfra, fie_ima;
-       float norfac, *nor;
+       float norfac;
        
        struct Ipo *ipo;
        struct Image *ima;
index f90c8f0158a20f582528060d6f13c02089d4dfbe..bcfb495b2381e7deb837846b3cc8ad8add1915af 100644 (file)
@@ -44,7 +44,6 @@
 #include <butspace.h>
 #include <BKE_bad_level_calls.h>
 #include "sceneRender.h"
-#include "render_types.h"
 #include "blendef.h"
 #include "Scene.h"
 #include "gen_utils.h"
@@ -792,30 +791,30 @@ PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
                                                "expected a list" ) );
 
-       R.winpos = 0;
+       G.winpos = 0;
        for( x = 0; x < PyList_Size( list ); x++ ) {
                if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
                        return EXPP_ReturnPyObjError( PyExc_TypeError,
                                                      "python list not parseable\n" );
                }
                if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
-                       R.winpos |= 1;
+                       G.winpos |= 1;
                else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
-                       R.winpos |= 2;
+                       G.winpos |= 2;
                else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
-                       R.winpos |= 4;
+                       G.winpos |= 4;
                else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
-                       R.winpos |= 8;
+                       G.winpos |= 8;
                else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
-                       R.winpos |= 16;
+                       G.winpos |= 16;
                else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
-                       R.winpos |= 32;
+                       G.winpos |= 32;
                else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
-                       R.winpos |= 64;
+                       G.winpos |= 64;
                else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
-                       R.winpos |= 128;
+                       G.winpos |= 128;
                else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
-                       R.winpos |= 256;
+                       G.winpos |= 256;
                else
                        return EXPP_ReturnPyObjError( PyExc_AttributeError,
                                                      "list contains unknown string\n" );
@@ -828,7 +827,7 @@ PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
 //------------------------------------Render.EnableDispView() -----------
 PyObject *M_Render_EnableDispView( PyObject * self )
 {
-       R.displaymode = R_DISPLAYVIEW;
+       G.displaymode = R_DISPLAYVIEW;
        allqueue( REDRAWBUTSSCENE, 0 );
 
        return EXPP_incr_ret( Py_None );
@@ -837,7 +836,7 @@ PyObject *M_Render_EnableDispView( PyObject * self )
 //------------------------------------Render.EnableDispWin() ------------
 PyObject *M_Render_EnableDispWin( PyObject * self )
 {
-       R.displaymode = R_DISPLAYWIN;
+       G.displaymode = R_DISPLAYWIN;
        allqueue( REDRAWBUTSSCENE, 0 );
 
        return EXPP_incr_ret( Py_None );
@@ -919,14 +918,14 @@ PyObject *RenderData_Play( BPy_RenderData * self )
                }
        }
        if( BLI_exist( file ) ) {
-               calc_renderwin_rectangle( R.winpos, pos, size );
+               calc_renderwin_rectangle( G.winpos, pos, size );
                sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
                         pos[1], file );
                system( str );
        } else {
                makepicstring( file, self->renderContext->sfra );
                if( BLI_exist( file ) ) {
-                       calc_renderwin_rectangle( R.winpos, pos, size );
+                       calc_renderwin_rectangle( G.winpos, pos, size );
                        sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
                                 pos[0], pos[1], file );
                        system( str );
index e4c4f7edf1394f10b9d7b092d75f86c25b1d5de7..b7761cd97d4af5df9b996606367d97ce4e20e5b2 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 Import ('user_options_dict')
 Import ('library_env')
+Import ('sdl_env')
 
 render_env = library_env.Copy ()
 
@@ -9,6 +10,7 @@ source_files = ['intern/source/RE_callbacks.c',
                 'intern/source/envmap.c',
                 'intern/source/errorHandler.c',
                 'intern/source/gammaCorrectionTables.c',
+                'intern/source/imagetexture.c',
                 'intern/source/initrender.c',
                 'intern/source/jitter.c',
                 'intern/source/pixelblending.c',
@@ -36,6 +38,7 @@ render_env.Append (CPPPATH = ['intern/include',
                               '../quicktime',
                               '../include',
                               '../../kernel/gen_messaging',
-                              '../yafray'])
+                              '../yafray'] +
+                             sdl_env['CPPPATH'])
 
 render_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/blender_render', source=source_files)
index d39532046782e54313ccbdc175b0217e40886d8e..209cf52b2505d85c977b35faaf062a8ea86723f3 100644 (file)
@@ -40,9 +40,6 @@
 /* fixes. I think it is risky to always include it...                        */
 /* ------------------------------------------------------------------------- */
 
-/* fix for OSA and defmaterial extern */
-#include "BKE_osa_types.h"
-#include "DNA_material_types.h"
 
 #ifdef __cplusplus
 extern "C" { 
@@ -69,8 +66,6 @@ extern "C" {
 /* ------------------------------------------------------------------------- */
 
 extern RE_Render         R;           /* rendercore.c */
-extern Osa               O;           /* rendercore.c */
-extern Material          defmaterial; /* initrender.c */
 extern unsigned short   *igamtab1;    /* initrender.c */
 extern unsigned short   *gamtab;      /* initrender.c */
 
@@ -80,7 +75,7 @@ struct View3D;
 /* Function definitions                                                      */
 /*                                                                           */
 /* All functions that need to be externally visible must be declared here.   */
-/* Currently, this interface contains 29 functions and 11 callbacks.         */
+/* Currently, this interface contains 38 functions and 11 callbacks.         */
 /* ------------------------------------------------------------------------- */
 
 
@@ -88,11 +83,12 @@ struct View3D;
 /* shadbuf.c (1)                                                           */
 /* ------------------------------------------------------------------------- */
 
+/* only for renderconvertor */
 void RE_initshadowbuf(struct LampRen *lar, float mat[][4]);
 
 
 /* ------------------------------------------------------------------------- */
-/* initrender (14)                                                           */
+/* initrender (9)                                                           */
 /* ------------------------------------------------------------------------- */
 
 struct View3D;
@@ -107,7 +103,7 @@ struct View3D;
 void    RE_initrender(struct View3D *ogl_render_view3d);
 
 /**
- *
+ * only for renderconvertor
  */
 void    RE_setwindowclip(int mode, int jmode);
 
@@ -117,12 +113,12 @@ void    RE_setwindowclip(int mode, int jmode);
  */
 void    RE_animrender(struct View3D *ogl_render_view3d);
 void    RE_free_render_data(void);
-void    RE_free_filt_mask(void);
-void    RE_init_filt_mask(void);
 void    RE_init_render_data(void);
+               /* jitterate is used by blenkernel effect */
 void    RE_jitterate1(float *jit1, float *jit2, int num, float rad1);
 void    RE_jitterate2(float *jit1, float *jit2, int num, float rad2);
 void    RE_make_existing_file(char *name);
+void    RE_floatbuffer_to_output(void);
 
 /* ------------------------------------------------------------------------- */
 /* zbuf (2)                                                                  */
@@ -151,7 +147,7 @@ void    RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_t
 
 
 /* ------------------------------------------------------------------------- */
-/* texture                                                                    */
+/* texture  (9)                                                                  */
 /* ------------------------------------------------------------------------- */
 struct MTex;
 struct Tex;
@@ -161,17 +157,11 @@ void end_render_textures(void);
 void init_render_texture(struct Tex *tex);
 void end_render_texture(struct Tex *tex);
 
-void tubemap(float x, float y, float z, float *adr1, float *adr2);
-void spheremap(float x, float y, float z, float *adr1, float *adr2);
-
 void do_material_tex(ShadeInput *shi);
-void externtex(struct MTex *mtex, float *vec);
-void externtexcol(struct MTex *mtex, float *orco, char *col);
-void do_lamp_tex(struct LampRen *la, float *lavec, ShadeInput *shi);
-void do_sky_tex(float *);
-
-int multitex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex);
+void do_lamp_tex(struct LampRen *la, float *lavec, ShadeInput *shi, float *fcol);
 
+int multitex_ext(struct Tex *tex, float *texvec, float *tin, float *tr, float *tg, float *tb, float *ta);
+void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta);
 
 /* ------------------------------------------------------------------------- */
 /* envmap (4)                                                                   */
@@ -186,7 +176,7 @@ struct EnvMap *RE_add_envmap(void);
 struct EnvMap *RE_copy_envmap(struct EnvMap *env);
 
 /* --------------------------------------------------------------------- */
-/* rendercore (2)                                                        */
+/* rendercore (10)                                                        */
 /* --------------------------------------------------------------------- */
 float Phong_Spec(float *n, float *l, float *v, int hard);
 float CookTorr_Spec(float *n, float *l, float *v, int hard);
@@ -206,9 +196,8 @@ void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi)
 struct VlakRen *RE_findOrAddVlak(int nr);
 struct VertRen *RE_findOrAddVert(int nr);
 struct HaloRen *RE_findOrAddHalo(int nr);
-HaloRen *RE_inithalo(Material *ma, float *vec, float *vec1, float *orco, float hasize, 
-                                       float vectsize);
-
+HaloRen *RE_inithalo(struct Material *ma, float *vec, float *vec1, float *orco, float hasize, 
+                                       float vectsize, int seed);
 
 /**
        * callbacks (11):
@@ -255,13 +244,13 @@ int RE_testclip(float *v);
 /* patch for the external if, to support the split for the ui */
 void RE_addalphaAddfac(char *doel, char *bron, char addfac);
 void RE_sky_char(float *view, char *col); 
-void RE_sky(float *view, float *col); 
 void RE_renderflare(struct HaloRen *har); 
 /**
        * Shade the pixel at xn, yn for halo har, and write the result to col. 
        * Also called in: previewrender.c
        * @param har    The halo to be rendered on this location
-       * @param col    [unsigned int 3] The destination colour vector 
+       * @param col    [char 4] The destination colour vector 
+       * @param colf   [float 4] destination colour vector (need both)
        * @param zz     Some kind of distance
        * @param dist   Square of the distance of this coordinate to the halo's center
        * @param x      [f] Pixel x relative to center
@@ -269,7 +258,7 @@ void RE_renderflare(struct HaloRen *har);
        * @param flarec Flare counter? Always har->flarec...
        */
 void RE_shadehalo(struct HaloRen *har,
-                               char *col,
+                               char *col, float *colf, 
                                unsigned int zz,
                                float dist,
                                float x,
index 9f1fb9efef229671abc5753fb0b31085a076b9ad..f8826228535e1242133306f587125762ce7b2765 100644 (file)
 
 /* ------------------------------------------------------------------------- */
 
+/* localized texture result data */
+typedef struct TexResult {
+       float tin, tr, tg, tb, ta;
+       int talpha;
+       float *nor;
+} TexResult;
+
 /* localized renderloop data */
 typedef struct ShadeInput
 {
-       struct Material *mat, *matren;
+       struct Material *mat;
        struct VlakRen *vlr;
        float co[3];
+       
+       /* copy from material, keep synced so we can do memcopy */
+       /* current size: 23*4 */
+       float r, g, b;
+       float specr, specg, specb;
+       float mirr, mirg, mirb;
+       float ambr, ambb, ambg;
+       
+       float amb, emit, ang, spectra, ray_mirror;
+       float alpha, refl, spec, zoffs, add;
+       float translucency;
+       /* end direct copy from material */
+       
+       /* individual copies: */
+       int har;
+       
+       /* texture coordinates */
        float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3];
        float vn[3], view[3], refcol[4], displace[3];
+       /* dx/dy OSA coordinates */
+       float dxco[3], dyco[3];
+       float dxlo[3], dylo[3], dxgl[3], dygl[3], dxuv[3], dyuv[3];
+       float dxref[3], dyref[3], dxorn[3], dyorn[3];
+       float dxno[3], dyno[3], dxview, dyview;
+       float dxlv[3], dylv[3];
+       float dxwin[3], dywin[3];
+       float dxsticky[3], dysticky[3];
+       float dxrefract[3], dyrefract[3];
+       
        float xs, ys;   /* pixel to be rendered */
        short osatex;
        int mask;
@@ -69,7 +103,7 @@ typedef struct ShadeInput
 /* here only stuff to initalize the render itself */
 typedef struct RE_Render
 {
-       float grvec[3], inprz, inprh;
+       float grvec[3];
        float imat[3][3];
 
        float viewmat[4][4], viewinv[4][4];
@@ -113,6 +147,7 @@ typedef struct RE_Render
        unsigned int *rectspare; /*  */
        /* for 8 byte systems! */
        long *rectdaps;
+       float *rectftot;        /* original full color buffer */
        
        short win, winpos, winx, winy, winxof, winyof;
        short winpop, displaymode, sparex, sparey;
@@ -125,17 +160,6 @@ typedef struct RE_Render
 
 /* ------------------------------------------------------------------------- */
 
-/** 
- * Part as in part-rendering. An image rendered in parts is rendered
- * to a list of parts, with x,y size, and a pointer to the render
- * output stored per part. Internal!
- */
-typedef struct Part
-{
-       struct Part *next, *prev;
-       unsigned int *rect;
-       short x, y;
-} Part;
 
 typedef struct ShadBuf {
        short samp, shadhalostep;
@@ -186,14 +210,14 @@ typedef struct RadFace {
 typedef struct VlakRen
 {
        struct VertRen *v1, *v2, *v3, *v4;
+       unsigned int lay;
+       unsigned int raycount;
        float n[3];
        struct Material *mat;
        struct TFace *tface;
        unsigned int *vcol;
        char snproj, puno;
        char flag, ec;
-       unsigned int lay;
-       unsigned int raycount;
        RadFace *radface;
        Object *ob;
 } VlakRen;
@@ -202,12 +226,12 @@ typedef struct VlakRen
 
 typedef struct HaloRen
 {      
+    short miny, maxy;
     float alfa, xs, ys, rad, radsq, sin, cos, co[3], no[3];
+       float hard, b, g, r;
     unsigned int zs, zd;
-    unsigned int zBufDist;/* depth in the z-buffer coordinate system */
-    short miny, maxy;
-    short hard, b, g, r;
-    char starpoints, add, type, tex;
+    unsigned int zBufDist;     /* depth in the z-buffer coordinate system */
+    char starpoints, type, add, tex;
     char linec, ringc, seed;
        short flarec; /* used to be a char. why ?*/
     float hasize;
@@ -274,9 +298,9 @@ typedef struct LampRen
        /* ray optim */
        VlakRen *vlr_last;
        
-       struct LampRen *org;
        struct MTex *mtex[MAX_MTEX];
 } LampRen;
 
+
 #endif /* RENDER_TYPES_H */
 
index c77bb01f6ac7e91915cca6c729ea01aa56af3200..7a44a139b20cbe43d2315c7a04f04aba2f4a5f26 100644 (file)
  * environment map as texture. 
  * (initrender.c)
  */
+
+struct TexResult;
+
 void make_envmaps(void);
-int     envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex);
+int     envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres);
 
 #endif /* ENVMAP_EXT_H */
 
index 8df743e468d7bdfe83c3c26015869e26fa87ff08..6197f769f6f117baaa1090ea2c3cefc413a9d2f3 100644 (file)
@@ -67,12 +67,7 @@ float invGammaCorrect(float col);
 /**
  * Tell whether or not to do gamma.
  */
-int doGamma(void);
-
-/**
- * Set/unset performing gamma corrections.
- */
-void setDoGamma(int);
+extern int do_gamma;
 
 #endif
 
index 06c5f032c7d70fd1de5653e442aa08560c293b91..15ec3eb69a3c50ad9511cc55d9b358b2d065f76c 100644 (file)
 
 /* Functions */
 
-void init_def_material(void);
-void init_render_jit(int nr);
-float  calc_weight(float *weight, int i, int j);
-void defaultlamp(void);
 void schrijfplaatje(char *name);
-void initparts(void);
-short setpart(short nr); /* return 0 als geen goede part */
-void addparttorect(short nr, Part *part);
-void add_to_blurbuf(int blur);
-void oldRenderLoop(void); /* Calls the old renderer. Contains the PART and FIELD loops. */
 void render(void);  /* Switch between the old and the unified renderer. */
 /*  void write_screendump(char *name); not here !*/
 
index f270207cc2286b681543e94b0fd0e61cb1cf9e58..696ded297b13ea8233d889dc6bc3fd40df0a676c 100644 (file)
@@ -41,7 +41,8 @@ extern "C" {
 
 extern float jit[64][2];
 
-void initjit(float *jitarr, int num);
+extern void initjit(float *jitarr, int num);
+extern void init_render_jit(int nr);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/render/intern/include/old_zbuffer_types.h b/source/blender/render/intern/include/old_zbuffer_types.h
deleted file mode 100644 (file)
index 4adf5f0..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- * Datatypes for old zbuffering algorithms.
- */
-
-#ifndef OLD_ZBUFFER_TYPES_H
-#define OLD_ZBUFFER_TYPES_H "$Id$"
-
-typedef struct PixStr
-{
-       struct PixStr *next;
-       int vlak0, vlak;
-       unsigned int z;
-       unsigned int mask;
-       short aantal, ronde;
-} PixStr;
-
-/* ------------------------------------------------------------------------- */
-
-typedef struct PixStrMain
-{
-       struct PixStr *ps;
-       struct PixStrMain *next;
-} PixStrMain;
-
-/* ------------------------------------------------------------------------- */
-
-#endif
-
index b413bc8b8a12907a66351c60705c21cc2b71bc31..f5e96d075dac8bf890912a4ae313c42b4df329a9 100644 (file)
 /* local includes */
 #include "vanillaRenderPipe_types.h"
 
-/* own include */
-#include "pixelblending_types.h"
-
-/**
- * Samples pixel, depending on R.osa setting
- */
-int addtosampcol(unsigned short *sampcol, unsigned short *shortcol, int mask);
-
-/**
- * Samples pixel, bring your own R.osa setting
- */
-int addToSampCol(unsigned short *sampcol, unsigned short *shortcol, int mask, int osaNr);
-
 /**
  * Halo-add pixel, bring your own R.osa setting, and add factor
  */
diff --git a/source/blender/render/intern/include/pixelblending_types.h b/source/blender/render/intern/include/pixelblending_types.h
deleted file mode 100644 (file)
index dac9924..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * pixelblending_types.h
- * types pixelblending 
- *
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef PIXELBLENDING_TYPES_H
-#define PIXELBLENDING_TYPES_H
-
-/* Threshold for a 'full' pixel: pixels with alpha above this level are      */
-/* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF           */
-#define RE_FULL_COLOUR_FLOAT 0.9998
-/* Threshold for an 'empty' pixel: pixels with alpha above this level are    */
-/* considered completely transparent. This is the decimal value              */
-/* for 0x000F / 0xFFFF                                                       */
-#define RE_EMPTY_COLOUR_FLOAT 0.0002
-/* A 100% pixel. Sometimes, seems to be too little.... Hm.......             */
-#define RE_UNITY_COLOUR_FLOAT 1.0
-/* A 0% pixel. I wonder how 0 the 0.0 is...                                  */
-#define RE_ZERO_COLOUR_FLOAT 0.0
-
-/* threshold for alpha                                                       */
-#define RE_FULL_ALPHA_FLOAT 0.9998
-
-/* Same set of defines for shorts                                            */
-#define RE_FULL_COLOUR_SHORT 0xFFF0
-#define RE_EMPTY_COLOUR_SHORT 0x0000
-
-#endif /* PIXELBLENDING_EXT_H */
-
index dd429f9ff61f6a2800e789205131e9a65042f2f5..2f888cf05cf61ed76b162d0d940163b73357718b 100644 (file)
  * mask is pixel coverage in bits
  * @return pointer to the object
  */
-void *renderPixel(float x, float y, int *t, int mask);
+void *renderPixel(RE_COLBUFTYPE *collector, float x, float y, int *t, int mask);
 
-void *renderHaloPixel(float x, float y, int haloNr) ;
+void *renderHaloPixel(RE_COLBUFTYPE *collector, float x, float y, int haloNr) ;
 
 
 void setSkyBlendingMode(enum RE_SkyAlphaBlendingType mode);
+
 void shadeHaloFloat(HaloRen *har, 
                                        float *col, unsigned int zz, 
                                        float dist, float xn, 
@@ -69,13 +70,14 @@ enum RE_SkyAlphaBlendingType getSkyBlendingMode(void);
 /**
  * Render the sky at pixel (x, y).
  */
-void renderSkyPixelFloat(float x, float y);
+void renderSkyPixelFloat(RE_COLBUFTYPE *collector, float x, float y);
 
 /* used by shadeSkyPixel: */
-void shadeSkyPixelFloat(float y, float *view);
+void shadeSkyPixelFloat(float *colf, float *view, float *dxyview);
 void renderSpotHaloPixel(float x, float y, float *target);
-void shadeSkyPixel(float fx, float fy);
-void fillBackgroundImage(float x, float y);
+void shadeSkyPixel(RE_COLBUFTYPE *collector, float fx, float fy);
+void fillBackgroundImage(RE_COLBUFTYPE *collector, float x, float y);
+void fillBackgroundImageChar(char *col, float x, float y);
 
 /* ------------------------------------------------------------------------- */
 
diff --git a/source/blender/render/intern/include/render_intern.h b/source/blender/render/intern/include/render_intern.h
deleted file mode 100644 (file)
index 25302ad..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * render_int.h
- * misc internal defines for renderer
- *
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-       /* XXX, should die, no good reason to write 
-        * regular (non-file related) endian dependant
-        * code.
-        */
-#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
-#define RCOMP  3
-#define GCOMP  2
-#define BCOMP  1
-#define ACOMP  0
-#else
-#define RCOMP  0
-#define GCOMP  1
-#define BCOMP  2
-#define ACOMP  3
-#endif
-
-#define VECCOPY(v1,v2)                 {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
-#define QUATCOPY(v1,v2)        {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
-
-#define CLAMPIS(a, b, c)       ((a)<(b) ? (b) : (a)>(c) ? (c) : (a))
-
-typedef struct { 
-       int a, b, c, d;
-} byte16;
-
-#define COPY_16(a,b)           (*((byte16 *)(a))= *((byte16 *)(b)))
-
index 964300ad27ba69d0062ec22b8a638fffc9707ad9..e66e405d3830ac99cc0254baf7717505f7de7b7f 100644 (file)
@@ -54,20 +54,36 @@ typedef struct ShadeResult
 
 } ShadeResult;
 
-float   mistfactor(float *co); /* dist en hoogte, return alpha */
+typedef struct PixStr
+{
+       struct PixStr *next;
+       int vlak0, vlak;
+       unsigned int z;
+       unsigned int mask;
+       short aantal, ronde;
+} PixStr;
+
+/* ------------------------------------------------------------------------- */
+
+typedef struct PixStrMain
+{
+       struct PixStr *ps;
+       struct PixStrMain *next;
+} PixStrMain;
+
+
+float   mistfactor(float *co); /* dist and height, return alpha */
 
-void   render_lighting_halo(struct HaloRen *har, float *colf);
-unsigned int    calchalo_z(struct HaloRen *har, unsigned int zz);
-void add_halo_flare(void);
+void   add_halo_flare(void);
 
-void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, int i3);
+void   shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, int i3);
 
-void shade_color(struct ShadeInput *shi, ShadeResult *shr);
-void shade_lamp_loop(struct ShadeInput *shi, ShadeResult *shr);
+void   shade_color(struct ShadeInput *shi, ShadeResult *shr);
+void   shade_lamp_loop(struct ShadeInput *shi, ShadeResult *shr);
 
-float fresnel_fac(float *view, float *vn, float fresnel, float fac);
-void calc_R_ref(struct ShadeInput *shi);
-float spec(float inp, int hard);
+float  fresnel_fac(float *view, float *vn, float fresnel, float fac);
+void   calc_R_ref(struct ShadeInput *shi);
+float  spec(float inp, int hard);
 
 /* -------- ray.c ------- */
 
@@ -76,36 +92,12 @@ extern void ray_trace(ShadeInput *, ShadeResult *);
 extern void ray_ao(ShadeInput *, World *, float *);
 
 /**
- * Apply the background (sky). Depending on the active alphamode and
- * worldmode, different filling strategies are applied.
- * Active alphamode = R.r.alphamode
- * Active worldmode = R.wrld.mode
- * <LI>
- * <IT> R_ALPHAPREMUL - do not fill sky, but apply alpha to colours
- * <IT> R_ALPHAKEY    - do not fill sky, do not apply alpha to colours
- * <IT> R_ADDSKY      - fill skycolour in the background, blend
- *                      transparent colours with the background
- * (there's also a world dependency here?
- *   <LI>
- *   <IT> R.wrld.mode == WO_MIST
- *   <IT> R.r.bufflag == 1, R.flag == R_SEC_FIELD
- *   <IT> R.wrld.skytype == ( WO_SKYBLEND ^ WO_SKYTEX)
- *   <IT>   R.wrld.skytype == WO_SKYPAPER
- *   <IT> R.r.mode == R_PANORAMA )
- *   </LI>
- * </LI>
- * @param rect
- * @param y 
- */
-void scanlinesky(char *rect, int y);
-
-/**
- * Do z buffer stuff.
+ * Do z buffer and shade
  */
 void zbufshade(void);
 
 /**
- * Insert transparent faces into the z buffer?
+ * zbuffer and shade, anti aliased
  */
 void zbufshadeDA(void);        /* Delta Accum Pixel Struct */
 
@@ -113,20 +105,6 @@ void zbufshadeDA(void);    /* Delta Accum Pixel Struct */
  * Also called in: zbuf.c
  */
 void *shadepixel(float x, float y, int vlaknr, int mask, float *col);
-void shadepixel_short(float x, float y, int vlaknr, int mask, unsigned short *shortcol);
-
-/**
- * Shade the pixel at xn, yn for halo har, and write the result to col. 
- * Also called in: previewrender.c
- * @param har    The halo to be rendered on this location
- * @param col    [unsigned int 3] The destination colour vector 
- * @param zz     Some kind of distance
- * @param dist   Square of the distance of this coordinate to the halo's center
- * @param x      [f] Pixel x relative to center
- * @param y      [f] Pixel y relative to center
- * @param flarec Flare counter? Always har->flarec...
- */
-/*  void shadehalo(struct HaloRen *har, char *col, unsigned int zz, float dist, float x, float y, short flarec); */
 
 /**
  * A cryptic but very efficient way of counting the number of bits that 
diff --git a/source/blender/render/intern/include/rendercore_int.h b/source/blender/render/intern/include/rendercore_int.h
deleted file mode 100644 (file)
index 6b6ae89..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * render_int.h
- *
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef RENDER_INT_H
-#define RENDER_INT_H
-
-#include "zbuf_types.h"
-#include "render_types.h"
-
-void    spothalo(struct LampRen *lar, ShadeInput *shi, float *intens);
-void    add_filt_mask(unsigned int mask, unsigned short *col, unsigned int *rb1, unsigned int *rb2, unsigned int *rb3);
-void    addps(long *rd, int vlak, unsigned int z, short ronde);
-PixStr *addpsmain(void);
-float   count_maskf(unsigned short mask);
-void    freeps(void);
-void    halovert(void);
-void    renderhalo(HaloRen *har);      /* postprocess versie */
-void scanlinehaloPS(unsigned int *rectz, long *rectdelta, unsigned int *rectt, short ys);
-
-#endif /* RENDER_INT_H */
-
index f0bdcd224b6b3c4f28e3367a914a6555e3c6b8a5..279d5319b21823fa5df274e8a7dd3c94be63ed6d 100644 (file)
@@ -52,7 +52,7 @@ void makeshadowbuf(LampRen *lar);
  * @param inp The inproduct between viewvector and ?
  *
  */
-float testshadowbuf(struct ShadBuf *shb, float *rco, float inp);       
+float testshadowbuf(struct ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp);     
 
 /**
  * Determines the shadow factor for lamp <lar>, between <p1>
index 9932f5a60eac29cd917ff4049a73ab565f797368..866f631dac6e4e8318b18d9b59260967b8c3d199 100644 (file)
 #ifndef TEXTURE_EXT_H
 #define TEXTURE_EXT_H
 
+#define BRICONT                texres->tin= (texres->tin-0.5)*tex->contrast+tex->bright-0.5; \
+if(texres->tin<0.0) texres->tin= 0.0; else if(texres->tin>1.0) texres->tin= 1.0;
+
+#define BRICONTRGB     texres->tr= tex->rfac*((texres->tr-0.5)*tex->contrast+tex->bright-0.5); \
+if(texres->tr<0.0) texres->tr= 0.0; \
+texres->tg= tex->gfac*((texres->tg-0.5)*tex->contrast+tex->bright-0.5); \
+if(texres->tg<0.0) texres->tg= 0.0; \
+texres->tb= tex->bfac*((texres->tb-0.5)*tex->contrast+tex->bright-0.5); \
+if(texres->tb<0.0) texres->tb= 0.0; 
+
+
 struct HaloRen;
 struct ShadeInput;
+struct TexResult;
+struct Tex;
+
+/* texture.h */
 
 void do_halo_tex(struct HaloRen *har, float xn, float yn, float *colf);
+void do_sky_tex(float *lo, float *dxyview, float *hor, float *zen, float *blend);
 void render_realtime_texture(struct ShadeInput *shi);           
 
+/* imagetexture.h */
+
+int imagewraposa(struct Tex *tex, float *texvec, float *dxt, float *dyt, struct TexResult *texres);
+int imagewrap(struct Tex *tex, float *texvec, struct TexResult *texres);
 
 #endif /* TEXTURE_EXT_H */
 
index 1ace0c23610807241f5469a93476d95dff00bbdf..f242b8522fc3faada5eb02c20b018f9281019566 100644 (file)
  */
 void zBufShadeAdvanced(void);
 
+/**
+ * Copy the colour buffer output to R.rectot, to line y.
+ */
+void transferColourBufferToOutput(float *buf, int y);
+/**
+ * using default transforms for brightness, gamma, hue, saturation etc. 
+ */
+void std_floatcol_to_charcol(float *buf, char *target);
+
+
 #endif /* VANILLARENDERPIPE_EXT_H */
 
diff --git a/source/blender/render/intern/include/vanillaRenderPipe_int.h b/source/blender/render/intern/include/vanillaRenderPipe_int.h
deleted file mode 100644 (file)
index 980befa..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * vanillaRenderPipe_int.h
- *
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef VANILLARENDERPIPE_INT_H
-#define VANILLARENDERPIPE_INT_H
-
-#include "vanillaRenderPipe_types.h"
-#include "zbufferdatastruct_types.h"
-
-/**
- * Z buffer initializer, for new pipeline.
- * <LI>
- * <IT> AColourBuffer : colour buffer for one line
- * <IT> APixbufExt    : pixel data buffer for one line, depth RE_ZBUFLEN 
- * </LI>
- */
-void initRenderBuffers(int width);
-/*  void initRenderBuffers(void); */
-
-/**
- * Z buffer destructor, frees stuff from initZBuffers().
- */
-void freeRenderBuffers(void);
-
-/** 
- * Fill the accumulation buffer APixbufExt with face and halo indices. 
- * Note: Uses globals.
- * @param y the line number to set
- */
-void calcZBufLine(int y);
-
-/** 
- * Shade and render the pixels in this line, into AColourBuffer
- * Note: Uses globals.
- * @param y the line number to set
- */
-void renderZBufLine(int y);
-
-/**
- * Count and sort the list behind ap into buf. Sorts on min. distance.
- * Low index <=> high z
- */
-int countAndSortPixelFaces(int buf[RE_MAX_FACES_PER_PIXEL][5], 
-                           RE_APixstrExt *ap);
-
-/** 
- * Compose the conflict and colour stacks 
- * Note: Uses globals.
- */
-int composeStack(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE],
-                                struct RE_faceField* stack, int ptr,
-                                int totvlak, float x, float y, int osaNr);
-/**
- * Integrate conflicting layers.
- * Note: Uses globals.
- */
-int resolveConflict(struct RE_faceField* stack, int ptr, float x, float y);
-
-/**
- * Integrate the colour stack, defer conflicts.
- * Note: Uses globals.
- */
-void integrateStack(struct RE_faceField* stack, int ptr,
-                                       float x, float y, int osaNr);
-                                       
-/**
- * Calculate the view depth to this object on this location, with 
- * the current view parameters in R.
- */
-int calcDepth(float x, float y, void *data, int type);
-
-
-
-/**
- * Fills in distances of all faces in a z buffer, for given jitter settings.
- */
-int fillZBufDistances(void);
-
-/**
- * Fills in distances of faces in the z buffer.
- *
- * Halo z buffering ---------------------------------------------- 
- *
- * A halo is treated here as a billboard: no z-extension, always   
- * oriented perpendicular to the viewer. The rest of the z-buffer  
- * stores face-numbers first, then calculates colours as the       
- * final image is rendered. We'll use the same approach here,      
- * which differs from the original method (which was add halos per 
- * scan line). This means that the z-buffer now also needs to      
- * store info about what sort of 'thing' the index refers to.      
- *                                                                 
- * Halo extension:                                                 
- * h.maxy  ---------                                               
- *         |          h.xs + h.rad                                 
- *             |      h.xs                                         
- *                 |  h.xs - h.rad                                 
- * h.miny  ---------                                               
- *                                                                 
- * These coordinates must be clipped to picture size.              
- * I'm not quite certain about halo numbering.                     
- *                                                                 
- * Halos and jittering -------------------------------------------  
- *                                                                 
- * Halos were not jittered previously. Now they are. I wonder      
- * whether this may have some adverse effects here.                
- * @return 1 for succes, 0 if the operation was interrupted.
- */
-int zBufferAllFaces(void);
-
-/**
- * Fills in distances of halos in the z buffer.
- * @return 1 for succes, 0 if the operation was interrupted.
- */
-int zBufferAllHalos(void);
-
-/**
- * New fill function for z buffer, for edge-only rendering.
- */
-void zBufferFillEdge(float *vec1, float *vec2);
-
-/**
- * New fill function for z buffer.
- */
-void zBufferFillFace(float *v1, float *v2, float *v3);
-
-/**
- * One more filler: fill in halo data in z buffer.
- * Empty so far, but may receive content of halo loop.
- */
-void zBufferFillHalo(void);
-
-/**
- * Copy the colour buffer output to R.rectot, to line y.
- */
-void transferColourBufferToOutput(int y);
-
-/**
- * Set the colour buffer fields to zero.
- */
-void eraseColBuf(RE_COLBUFTYPE *buf);
-
-/**
- * Blend source over dest, and leave result in dest. 1 pixel.
- */
-void blendOverFloat(int type, float* dest, float* source, void* data);
-
-/**
- * Blend source over dest, and leave result in dest. 1 pixel into 
- * multiple bins.
- */
-void blendOverFloatRow(int type, float* dest, float* source, 
-                       void* data, int mask, int osaNr) ;
-
-/**
- * Do a post-process step on a finalized render image.
- */
-void std_transFloatColV2CharColV( RE_COLBUFTYPE *buf, char *target);
-
-#endif /* VANILLARENDERPIPE_INT_H */
-
index fdfa5b19abeee634cde56fc0e2c5a6cb743ec643..fe72db4ee41f571e34996886ca1cfbb7fc38d76f 100644 (file)
@@ -112,7 +112,7 @@ void zbuffershad(struct LampRen *lar);
  * Also called in: render.c
  * @param y the line number to set
  */
-void abufsetrow(int y);
+void abufsetrow(float *acolrow, int y);
 
 
 /**
@@ -165,12 +165,12 @@ int vergzvlak(const void *x1, const void *x2);
  * @param c2 
  * @param c3
  */
-void  zbufclip(float *f1, float *f2, float *f3, int c1, int c2, int c3);
+void  zbufclip(unsigned int zvlnr, float *f1, float *f2, float *f3, int c1, int c2, int c3);
 
 /**
  * same, for edges
  */
-void         zbufclipwire(struct VlakRen *vlr); 
+void         zbufclipwire(unsigned int zvlnr, struct VlakRen *vlr); 
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/render/intern/include/zbuf_int.h b/source/blender/render/intern/include/zbuf_int.h
deleted file mode 100644 (file)
index 59a394d..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * zbuf_int.h
- * internal interface for zbuf.h (ie. functions that are not used
- * anywhere else) 
- *
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef ZBUF_INT_H
-#define ZBUF_INT_H
-
-#include "render_types.h"
-#include "zbuf_types.h"
-
-/**
- * Convert a homogenous coordinate to a z buffer coordinate. The
- * function makes use of Zmulx, Zmuly, the x and y scale factors for
- * the screen, and Zjitx, Zjity, the pixel offset. (These are declared
- * in render.c) The normalised z coordinate must fall on [0, 1]. 
- * @param zco  [3, 4 floats] pointer to the resulting z buffer coordinate
- * @param hoco [4 floats] pointer to the homogenous coordinate of the
- * vertex in world space.
- */
-void hoco_to_zco(float *zco, float *hoco);
-
-/**
- * Fill the z buffer for alpha?
- *
- * This is one of the z buffer fill functions called in zbufclip() and
- * zbufwireclip(). 
- *
- * @param v1 [4 floats, world coordinates] first vertex
- * @param v2 [4 floats, world coordinates] second vertex
- * @param v3 [4 floats, world coordinates] third vertex
- */
-void zbufinvulAc(float *v1, float *v2, float *v3);
-
-/**
- * Fill the z buffer, but invert z order, and add the face index to
- * the corresponing face buffer.
- *
- * This is one of the z buffer fill functions called in zbufclip() and
- * zbufwireclip(). 
- *
- * @param v1 [4 floats, world coordinates] first vertex
- * @param v2 [4 floats, world coordinates] second vertex
- * @param v3 [4 floats, world coordinates] third vertex
- */
-void zbufinvulGLinv(float *v1, float *v2, float *v3);
-
-/**
- * Fill the z buffer, and add the face index to
- * the corresponing face buffer.  Writes into R.rectz and R.rectot. It
- * assumes that Zvlnr is set to the face index of the face under
- * consideration. Zvlnr is written into R.rectot. R.rectz
- *
- * This is one of the z buffer fill functions called in zbufclip() and
- * zbufwireclip(). 
- *
- * @param v1 [4 floats, world coordinates] first vertex
- * @param v2 [4 floats, world coordinates] second vertex
- * @param v3 [4 floats, world coordinates] third vertex
- */
-void zbufinvulGL(float *v1, float *v2, float *v3);
-
-/**
- * Fill the z buffer. The face buffer is not operated on!
- *
- * This is one of the z buffer fill functions called in zbufclip() and
- * zbufwireclip(). 
- *
- * @param v1 [4 floats, world coordinates] first vertex
- * @param v2 [4 floats, world coordinates] second vertex
- * @param v3 [4 floats, world coordinates] third vertex
- */
-void zbufinvulGL_onlyZ(float *v1, float *v2, float *v3);
-
-/**
- * Prints 3 unlabelled floating point values to stdout. Used for diagnostics.
- * @param v1 any float
- * @param v2 any float
- * @param v3 any float
- */
-void print3floats(float *v1, float *v2, float *v3);
-
-/**
- * Checks labda and uses this to make decision about clipping the line
- * segment from v1 to v2. labda is the factor by which the vector is
- * cut. ( calculate s + l * ( t - s )). The result is appended to the
- * vertex list of this face.
- * Note: uses globals.
- * (arguments: one int, one pointer to int... why?)
- * @param v1 start coordinate s
- * @param v2 target coordinate t
- * @param b1 
- * @param b2 
- * @param clve vertex vector.
- */
-static void  maakvertpira(float *v1, float *v2, int *b1, int b2, int *clve);
-
-/**
- * Sets labda: flag, and parametrize the clipping of vertices in
- * viewspace coordinates. labda = -1 means no clipping, labda in [0,
- * 1] means a clipping.
- * Note: uses globals.
- * @param v1 start coordinate s
- * @param v2 target coordinate t
- * @param b1 
- * @param b2 
- * @param b3
- * @param a index for coordinate (x, y, or z)
- */
-static void  clipp(float *v1, float *v2, int b1, int *b2, int *b3, int a);
-
-/**
- * Tests whether this coordinate is 'inside' or 'outside' of the view
- * volume? By definition, this is in [0, 1]. 
- * @param p vertex z difference plus coordinate difference?
- * @param q origin z plus r minus some coordinate?
- * @param u1 [in/out] clip fraction for ?
- * @param u2 [in/out]
- * @return 0 if point is outside, or 1 if the point lies on the clip
- *         boundary 
- */
-static short cliptestf(float p, float q, float *u1, float *u2);
-
-
-/* not documented yet */
-/* not sure if these should stay static... */
-
-static int   clipline(float *v1, float *v2);
-
-/**
- * Provide book-keeping for the z buffer data lists.
- */
-APixstr     *addpsmainA(void);
-void         freepsA(void);
-APixstr     *addpsA(void);
-
-/**
- * Fill function for the z buffer (fills lines)
- */
-void         zbuflineAc(float *vec1, float *vec2);
-void         zbufline(float *vec1, float *vec2);
-
-
-/**
- * Copy results from the solid face z buffering to the transparent
- * buffer.
- */
-void         copyto_abufz(int sample);
-
-/**
- * Do accumulation z buffering.
- */
-void         zbuffer_abuf(void);
-
-/**
- * Shade this face at this location in SCS.
- */
-void         shadetrapixel(float x, float y, int vlak, int mask, unsigned short *shortcol);
-
-/**
- * Determine the distance to the camera of this halo, in ZCS.
- */
-unsigned int         calcHaloDist(HaloRen *har);
-
-#endif /* ZBUF_INT_H */
-
index 400e6045c03fbe351ef4735a55f550c18ca583a2..b55084b708b31d9db6c6d066b8996e70a2b48f67 100644 (file)
@@ -58,6 +58,7 @@ CPPFLAGS += -I../../../../kernel/gen_messaging
 CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
 # not very neat: the rest of blender..
 CPPFLAGS += -I../../../include 
+CPPFLAGS += $(NAN_SDLCFLAGS)
 
 ifeq ($(WITH_QUICKTIME), true)
        CPPFLAGS += -DWITH_QUICKTIME
index c6b74867c7346ad60cd359340f51284971a4b44c..acc115b2b87fecd689e44abb55fbee73e32c8bac 100644 (file)
@@ -34,7 +34,6 @@
 #include <stdlib.h> /* for NULL??? */
 #include <stdio.h>
 #include "render.h"
-#include "render_intern.h"
 #include "RE_callbacks.h"
 
 #ifdef HAVE_CONFIG_H
index 51d24236cd3b71f48636d5081cf20a6e26adeb5d..2181224871b35560feaa064d17cbb93466d73aeb 100644 (file)
 
 #include "MEM_guardedalloc.h"
 #include "MTC_vectorops.h"
+#include "BKE_utildefines.h"
 
 #include "RE_callbacks.h"
 #include "edgeRender.h"
 #include "render.h"
-#include "render_intern.h"
 #include "zbuf.h" /* for zbufclipwire and zbufclip */
 #include "jitter.h"
 
@@ -78,19 +78,13 @@ char edgeRender_c[] = "$Id$";
 #include "errorHandler.h"
 #endif
 
-/* ------------------------------------------------------------------------- */
-/* the lazy way: */
-#define MIN2(x,y)               ( (x)<(y) ? (x) : (y) )
-
 /* ------------------------------------------------------------------------- */
 
  /* These function pointers are used for z buffer filling.    */
-extern void (*zbuffunc)(float *, float *, float *);
-extern void (*zbuflinefunc)(float *, float *); 
+extern void (*zbuffunc)(unsigned int, float *, float *, float *);
+extern void (*zbuflinefunc)(unsigned int, float *, float *); 
 extern float Zmulx, Zmuly;   /* Some kind of scale?                          */
 extern float Zjitx,Zjity;    /* The x,y values for jitter offset             */
-extern unsigned int Zvlnr;           /* Face rendering pointer and counter: these    */
-extern VlakRen *Zvlr;        /* are used for 'caching' render results.       */
 
 /* ------------------------------------------------------------------------- */
 
@@ -148,12 +142,12 @@ void renderEdges(char * colourRect);
 /**
  * Buffer an edge between these two vertices in the e.r. distance buffer.
  */
-void fillEdgeRenderEdge(float *vec1, float *vec2);
+static void fillEdgeRenderEdge(unsigned int, float *vec1, float *vec2);
 
 /**
  * Buffer a face between these two vertices in the e.r. distance buffer.
  */
-void fillEdgeRenderFace(float *v1, float *v2, float *v3);
+static void fillEdgeRenderFace(unsigned int, float *v1, float *v2, float *v3);
 
 /**
  * Compose the edge render colour buffer.
@@ -598,6 +592,8 @@ void calcEdgeRenderColBuf(char* colTargetBuffer)
 /* rendering, this should be ok.                                             */
 int zBufferEdgeRenderObjects(void)
 {
+       VlakRen *vlr= NULL;
+       unsigned int zvlnr;
     int keepLooping; 
     int faceCounter; /* counter for face number */
     Material *ma;
@@ -607,30 +603,30 @@ int zBufferEdgeRenderObjects(void)
     faceCounter = 0;
                        
     while ( (faceCounter < R.totvlak) && keepLooping) {
-           if((faceCounter & 255)==0) { Zvlr= R.blovl[faceCounter>>8]; }
-           else Zvlr++;
+           if((faceCounter & 255)==0) { vlr= R.blovl[faceCounter>>8]; }
+           else vlr++;
         
-           ma= Zvlr->mat;
+           ma= vlr->mat;
 
            /*exp*/
            mat_cache = ma;
 
            /* face number is used in the fill functions */
-           Zvlnr = faceCounter + 1; 
+           zvlnr = faceCounter + 1; 
         
-           if(Zvlr->flag & R_VISIBLE) {
+           if(vlr->flag & R_VISIBLE) {
                        
                    /* here we cull all transparent faces if mode == 0 */
                    if (selectmode || !(ma->mode & MA_ZTRA)) {
                            /* here we can add all kinds of extra selection criteria */
-                           if(ma->mode & (MA_WIRE)) zbufclipwire(Zvlr);
+                           if(ma->mode & (MA_WIRE)) zbufclipwire(zvlnr, vlr);
                            else {
-                                   zbufclip(Zvlr->v1->ho,   Zvlr->v2->ho,   Zvlr->v3->ho, 
-                                            Zvlr->v1->clip, Zvlr->v2->clip, Zvlr->v3->clip);
-                                   if(Zvlr->v4) {
-                                           Zvlnr+= 0x800000; /* in a sense, the 'adjoint' face */
-                                           zbufclip(Zvlr->v1->ho,   Zvlr->v3->ho,   Zvlr->v4->ho, 
-                                                    Zvlr->v1->clip, Zvlr->v3->clip, Zvlr->v4->clip);
+                                   zbufclip(zvlnr, vlr->v1->ho,   vlr->v2->ho,   vlr->v3->ho, 
+                                            vlr->v1->clip, vlr->v2->clip, vlr->v3->clip);
+                                   if(vlr->v4) {
+                                           zvlnr+= 0x800000; /* in a sense, the 'adjoint' face */
+                                           zbufclip(zvlnr, vlr->v1->ho,   vlr->v3->ho,   vlr->v4->ho, 
+                                                    vlr->v1->clip, vlr->v3->clip, vlr->v4->clip);
                                    }
                            }
                    }
@@ -643,7 +639,7 @@ int zBufferEdgeRenderObjects(void)
 
 /* ------------------------------------------------------------------------- */
 
-void fillEdgeRenderFace(float *v1, float *v2, float *v3)  
+static void fillEdgeRenderFace(unsigned int zvlnr, float *v1, float *v2, float *v3)  
 {
        /* Coordinates of the vertices are specified in ZCS */
        double z0; /* used as temp var*/
@@ -851,7 +847,7 @@ void fillEdgeRenderFace(float *v1, float *v2, float *v3)
 
 /* ------------------------------------------------------------------------- */
 
-void fillEdgeRenderEdge(float *vec1, float *vec2)
+static void fillEdgeRenderEdge(unsigned int zvlnr, float *vec1, float *vec2)
 {
        int start, end, x, y, oldx, oldy, ofs;
        int dz, vergz/*  , mask */;
index f5a87ba7ae7914f6203d9fbfcca24c440d020a35..99ff21bd44e651f90f7c8dc2d51f0ebe7fcca558 100644 (file)
@@ -49,6 +49,8 @@
 #include "MEM_guardedalloc.h"
 #include "BLI_arithb.h"
 #include "BLI_blenlib.h"
+#include "BKE_utildefines.h"
+
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"        /* for rectcpy */
 
 #include "DNA_scene_types.h"
 #include "DNA_texture_types.h"
 
-#include "BIF_space.h"
-#include "BIF_toolbox.h"
-
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_global.h"
 #include "BKE_world.h"   // init_render_world
 #include "BKE_image.h"   // BKE_write_ibuf 
 
+#include "MTC_matrixops.h"
 
 /* this module */
 #include "RE_callbacks.h"
 #include "render.h"
-#include "render_intern.h"
 #include "envmap.h"
 #include "mydevice.h"
-#include "rendercore.h" /* calls zbufShade(DA).... I want to replace this with my own :)*/
+#include "rendercore.h" 
 #include "renderHelp.h"
-#include "MTC_matrixops.h"
+#include "texture.h"
 #include "zbuf.h"
 
-/* ------------------------------------------------------------------------- */
-
-void envmap_split_ima(EnvMap *env);
-void envmap_renderdata(EnvMap *env);
-void envmap_transmatrix(float mat[][4], int part);
-void env_rotate_scene(float mat[][4], int mode);
-void env_layerflags(unsigned int notlay);
-void env_set_imats(void);
-void render_envmap(EnvMap *env);
-int envcube_isect(float *vec, float *answ);
-static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int face);
 
 /* ------------------------------------------------------------------------- */
 
@@ -156,7 +144,7 @@ void RE_free_envmap(EnvMap *env)
 
 /* ------------------------------------------------------------------------- */
 
-void envmap_split_ima(EnvMap *env)
+static void envmap_split_ima(EnvMap *env)
 {
        ImBuf *ibuf;
        Image *ima;
@@ -168,7 +156,7 @@ void envmap_split_ima(EnvMap *env)
        dx= env->ima->ibuf->y;
        dx/= 2;
        if(3*dx != env->ima->ibuf->x) {
-               error("Incorrect envmap size");
+               printf("Incorrect envmap size\n");
                env->ok= 0;
                env->ima->ok= 0;
        }
@@ -199,7 +187,7 @@ void envmap_split_ima(EnvMap *env)
 /* ------------------------------------------------------------------------- */
 /* ****************** RENDER ********************** */
 
-void envmap_renderdata(EnvMap *env)
+static void envmap_renderdata(EnvMap *env)
 {
        static RE_Render envR;
        static Object *camera;
@@ -245,7 +233,7 @@ void envmap_renderdata(EnvMap *env)
 
 /* ------------------------------------------------------------------------- */
 
-void envmap_transmatrix(float mat[][4], int part)
+static void envmap_transmatrix(float mat[][4], int part)
 {
        float tmat[4][4], eul[3], rotmat[4][4];
        
@@ -277,7 +265,7 @@ void envmap_transmatrix(float mat[][4], int part)
 
 /* ------------------------------------------------------------------------- */
 
-void env_rotate_scene(float mat[][4], int mode)
+static void env_rotate_scene(float mat[][4], int mode)
 {
        VlakRen *vlr = NULL;
        VertRen *ver = NULL;
@@ -366,7 +354,7 @@ void env_rotate_scene(float mat[][4], int mode)
 
 /* ------------------------------------------------------------------------- */
 
-void env_layerflags(unsigned int notlay)
+static void env_layerflags(unsigned int notlay)
 {
        VlakRen *vlr = NULL;
        int a;
@@ -392,7 +380,7 @@ void env_hideobject(Object *ob)
 
 /* ------------------------------------------------------------------------- */
 
-void env_set_imats()
+static void env_set_imats()
 {
        Base *base;
        float mat[4][4];
@@ -409,7 +397,7 @@ void env_set_imats()
 
 /* ------------------------------------------------------------------------- */
 
-void render_envmap(EnvMap *env)
+static void render_envmap(EnvMap *env)
 {
        /* only the cubemap is implemented */
        ImBuf *ibuf;
@@ -420,6 +408,11 @@ void render_envmap(EnvMap *env)
        /* need a recalc: ortho-render has no correct viewinv */
        MTC_Mat4Invert(oldviewinv, R.viewmat);
 
+       /* do first, envmap_renderdata copies entire R struct */
+       if(R.rectz) MEM_freeN(R.rectz); R.rectz= NULL;
+       if(R.rectot) MEM_freeN(R.rectot); R.rectot= NULL;
+       if(R.rectftot) MEM_freeN(R.rectftot); R.rectftot= NULL;
+       
        /* setup necessary globals */
        envmap_renderdata(env);
        
@@ -480,8 +473,9 @@ void render_envmap(EnvMap *env)
 
        }
        
-       if(R.rectz) MEM_freeN(R.rectz); R.rectz= 0;
-       if(R.rectot) MEM_freeN(R.rectot); R.rectot= 0;
+       if(R.rectz) MEM_freeN(R.rectz); R.rectz= NULL;
+       if(R.rectot) MEM_freeN(R.rectot); R.rectot= NULL;
+       if(R.rectftot) MEM_freeN(R.rectftot); R.rectftot= NULL;
        
        if(RE_local_test_break()) RE_free_envmapdata(env);
        else {
@@ -557,7 +551,7 @@ void make_envmaps()
        if(do_init) {
                RE_local_init_render_display();
                RE_local_clear_render_display(R.win);
-               allqueue(REDRAWBUTSSHADING, 0);                 // bad!
+               R.flag |= R_REDRAW_PRV;
        }       
        // restore
        R.r.mode |= trace;
@@ -566,7 +560,7 @@ void make_envmaps()
 
 /* ------------------------------------------------------------------------- */
 
-int envcube_isect(float *vec, float *answ)
+static int envcube_isect(float *vec, float *answ)
 {
        float labda;
        int face;
@@ -639,17 +633,16 @@ static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int fac
 
 /* ------------------------------------------------------------------------- */
 
-extern float Tin, Ta, Tr, Tg, Tb; /* texture.c */
-int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
+int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
 {
        /* texvec should be the already reflected normal */
        EnvMap *env;
-       float fac, vec[3], sco[3], col[20], dxts[3], dyts[3];
+       float fac, vec[3], sco[3], dxts[3], dyts[3];
        int face, face1;
        
        env= tex->env;
        if(env==0 || env->object==0) {
-               Tin= 0.0;
+               texres->tin= 0.0;
                return 0;
        }
        if(env->stype==ENV_LOAD) {
@@ -662,7 +655,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
 
        if(env->ok==0) {
                
-               Tin= 0.0;
+               texres->tin= 0.0;
                return 0;
        }
        
@@ -674,16 +667,17 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
        tex->ima= env->cube[face];
        
        if(osatex) {
+
                MTC_Mat4Mul3Vecfl(env->object->imat, dxt);
                MTC_Mat4Mul3Vecfl(env->object->imat, dyt);
                
                set_dxtdyt(dxts, dyts, dxt, dyt, face);
-               imagewraposa(tex, sco, dxts, dyts);
+               imagewraposa(tex, sco, dxts, dyts, texres);
                
                /* edges? */
                
-               if(Ta<1.0) {
-                       col[0]= Ta; col[1]= Tr; col[2]= Tg; col[3]= Tb;
+               if(texres->ta<1.0) {
+                       TexResult texr1, texr2;
        
                        VecAddf(vec, vec, dxt);
                        face1= envcube_isect(vec, sco);
@@ -692,12 +686,11 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
                        if(face!=face1) {
                                tex->ima= env->cube[face1];
                                set_dxtdyt(dxts, dyts, dxt, dyt, face1);
-                               imagewraposa(tex, sco, dxts, dyts);
-                               col[4]= Ta; col[5]= Tr; col[6]= Tg; col[7]= Tb;
+                               imagewraposa(tex, sco, dxts, dyts, &texr1);
                        }
-                       else col[4]= col[5]= col[6]= col[7]= 0.0;
+                       else texr1.tr= texr1.tg= texr1.tb= texr1.ta= 0.0;
                        
-                       /* here was the nasty bug! col[5,6,7] were not zero-ed. FPE! */
+                       /* here was the nasty bug! results were not zero-ed. FPE! */
                        
                        VecAddf(vec, vec, dyt);
                        face1= envcube_isect(vec, sco);
@@ -706,23 +699,23 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
                        if(face!=face1) {
                                tex->ima= env->cube[face1];
                                set_dxtdyt(dxts, dyts, dxt, dyt, face1);
-                               imagewraposa(tex, sco, dxts, dyts);
-                               col[8]= Ta; col[9]= Tr; col[10]= Tg; col[11]= Tb;
+                               imagewraposa(tex, sco, dxts, dyts, &texr2);
                        }
-                       else col[8]= col[9]= col[10]= col[11]= 0.0;
-                       
-                       fac= (col[0]+col[4]+col[8]);
-                       fac= 1.0/fac;
+                       else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0;
                        
-                       Tr= fac*(col[0]*col[1] + col[4]*col[5] + col[8]*col[9] );
-                       Tg= fac*(col[0]*col[2] + col[4]*col[6] + col[8]*col[10] );
-                       Tb= fac*(col[0]*col[3] + col[4]*col[7] + col[8]*col[11] );
-                       Ta= 1.0;
-
+                       fac= (texres->ta+texr1.ta+texr2.ta);
+                       if(fac!=0.0) {
+                               fac= 1.0/fac;
+                               
+                               texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr );
+                               texres->tg= fac*(texres->ta*texres->tg + texr1.ta*texr1.tg + texr2.ta*texr2.tg );
+                               texres->tb= fac*(texres->ta*texres->tb + texr1.ta*texr1.tb + texr2.ta*texr2.tb );
+                       }
+                       texres->ta= 1.0;
                }
        }
        else {
-               imagewrap(tex, sco);
+               imagewrap(tex, sco, texres);
        }
        
        tex->ima= env->ima;
index ed72a68a9684ce0e979aaa21c0607ae479b8a2ef..0ab927a9cd94c60229ae7f81080f82390d282177 100644 (file)
@@ -33,8 +33,8 @@
 
 #include "GEN_messaging.h"
 #include "stdio.h"
+
 #include "errorHandler.h"
-#include "render_intern.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
index 8af6edf76da19fc84c5f85c0733f887ae6e92de3..0e27aacd9e36c4bca1d04390096da64d8e8958c8 100644 (file)
@@ -35,7 +35,6 @@
 #include "gammaCorrectionTables.h"
 #include <stdlib.h>
 #include <math.h>
-#include "render_intern.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -65,7 +64,7 @@ static float inv_colour_step;
 static float valid_gamma;
 static float valid_inv_gamma;
 static int   gamma_table_initialised = 0;
-static int   do_gamma;
+int   do_gamma=0;
 /* ------------------------------------------------------------------------- */
 
 float gammaCorrect(float c)
@@ -153,19 +152,5 @@ int gammaTableIsInitialised(void)
 }
 
 /* ------------------------------------------------------------------------- */
-int doGamma()
-{
-       return do_gamma;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/**
- * Set/unset performing gamma corrections.
- */
-void setDoGamma(int i)
-{
-       do_gamma = i;
-}
 
 /* eof */
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
new file mode 100644 (file)
index 0000000..e961729
--- /dev/null
@@ -0,0 +1,911 @@
+/**
+ *
+ * $Id:
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License.  See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <math.h>
+#ifndef WIN32 
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
+
+#include "MEM_guardedalloc.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "DNA_image_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_image.h"
+#include "BKE_texture.h"
+#include "BKE_library.h"
+
+#include "SDL_thread.h"
+
+#include "render.h"
+#include "texture.h"
+
+
+int imaprepeat, imapextend;
+
+
+/* *********** IMAGEWRAPPING ****************** */
+
+
+int imagewrap(Tex *tex, float *texvec, TexResult *texres)
+{
+       Image *ima;
+       struct ImBuf *ibuf;
+       float fx, fy, val1, val2, val3;
+       int ofs, x, y;
+       char *rect;
+
+       texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0;
+       ima= tex->ima;
+       if(ima==NULL || ima->ok== 0) {
+               return 0;
+       }
+       
+       if(ima->ibuf==NULL) {
+               extern SDL_mutex *load_ibuf_lock; // initrender.c
+               if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock);
+               if(ima->ibuf==NULL) ima_ibuf_is_nul(tex);
+               if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock);
+       }
+
+       if (ima->ok) {
+               ibuf = ima->ibuf;
+
+               if(tex->imaflag & TEX_IMAROT) {
+                       fy= texvec[0];
+                       fx= texvec[1];
+               }
+               else {
+                       fx= texvec[0];
+                       fy= texvec[1];
+               }
+               
+               if(tex->extend == TEX_CHECKER) {
+                       int xs, ys;
+                       
+                       xs= (int)floor(fx);
+                       ys= (int)floor(fy);
+                       fx-= xs;
+                       fy-= ys;
+
+                       if( (tex->flag & TEX_CHECKER_ODD)==0) {
+                               if((xs+ys) & 1);else return 0;
+                       }
+                       if( (tex->flag & TEX_CHECKER_EVEN)==0) {
+                               if((xs+ys) & 1) return 0; 
+                       }
+                       /* scale around center, (0.5, 0.5) */
+                       if(tex->checkerdist<1.0) {
+                               fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5;
+                               fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5;
+                       }
+               }
+
+               x = (int)(fx*ibuf->x);
+               y = (int)(fy*ibuf->y);
+
+               if(tex->extend == TEX_CLIPCUBE) {
+                       if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0 || texvec[2]>1.0) {
+                               return 0;
+                       }
+               }
+               else if( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
+                       if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) {
+                               return 0;
+                       }
+               }
+               else {
+                       if(tex->extend==TEX_EXTEND) {
+                               if(x>=ibuf->x) x = ibuf->x-1;
+                               else if(x<0) x= 0;
+                       }
+                       else {
+                               x= x % ibuf->x;
+                               if(x<0) x+= ibuf->x;
+                       }
+                       if(tex->extend==TEX_EXTEND) {
+                               if(y>=ibuf->y) y = ibuf->y-1;
+                               else if(y<0) y= 0;
+                       }
+                       else {
+                               y= y % ibuf->y;
+                               if(y<0) y+= ibuf->y;
+                       }
+               }
+               
+               /* warning, no return before setting back! */
+               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
+                       ibuf->rect+= (ibuf->x*ibuf->y);
+               }
+
+               ofs = y * ibuf->x + x;
+               rect = (char *)( ibuf->rect+ ofs);
+
+               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
+                       ibuf->rect-= (ibuf->x*ibuf->y);
+               }
+
+               if(tex->imaflag & TEX_USEALPHA) {
+                       if(tex->imaflag & TEX_CALCALPHA);
+                       else texres->talpha= 1;
+               }
+
+               texres->tr = ((float)rect[0])/255.0f;
+               texres->tg = ((float)rect[1])/255.0f;
+               texres->tb = ((float)rect[2])/255.0f;
+               
+               if(texres->nor) {
+                       if(tex->imaflag & TEX_NORMALMAP) {
+                               texres->nor[0]= 0.5-texres->tr;
+                               texres->nor[1]= 0.5-texres->tg;
+                               texres->nor[2]= -texres->tb;
+                       }
+                       else {
+                               /* bump: take three samples */
+                               val1= texres->tr+texres->tg+texres->tb;
+
+                               if(x<ibuf->x-1) {
+                                       rect+=4;
+                                       val2= ((float)(rect[0]+rect[1]+rect[2]))/255.0f;
+                                       rect-=4;
+                               }
+                               else val2= val1;
+
+                               if(y<ibuf->y-1) {
+                                       rect+= 4*ibuf->x;
+                                       val3= ((float)(rect[0]+rect[1]+rect[2]))/255.0f;
+                               }
+                               else val3= val1;
+
+                               /* do not mix up x and y here! */
+                               texres->nor[0]= (val1-val2);
+                               texres->nor[1]= (val1-val3);
+                       }
+               }
+
+               //BRICONTRGB;
+
+               if(texres->talpha) texres->ta= texres->tin= ((float)rect[3])/255.0f;
+               else if(tex->imaflag & TEX_CALCALPHA) {
+                       texres->ta= texres->tin= MAX3(texres->tr, texres->tg, texres->tb);
+               }
+               else texres->ta= texres->tin= 1.0;
+               
+               if(tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
+
+       }
+
+       if(texres->nor) return 3;
+       else return 1;
+}
+
+static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
+{
+       rctf *rf, *newrct;
+       short a;
+
+       a= *count;
+       rf= stack;
+       for(;a>0;a--) {
+               if(rf->xmin<x1) {
+                       if(rf->xmax<x1) {
+                               rf->xmin+= (x2-x1);
+                               rf->xmax+= (x2-x1);
+                       }
+                       else {
+                               if(rf->xmax>x2) rf->xmax= x2;
+                               newrct= stack+ *count;
+                               (*count)++;
+
+                               newrct->xmax= x2;
+                               newrct->xmin= rf->xmin+(x2-x1);
+                               newrct->ymin= rf->ymin;
+                               newrct->ymax= rf->ymax;
+                               
+                               if(newrct->xmin==newrct->xmax) (*count)--;
+                               
+                               rf->xmin= x1;
+                       }
+               }
+               else if(rf->xmax>x2) {
+                       if(rf->xmin>x2) {
+                               rf->xmin-= (x2-x1);
+                               rf->xmax-= (x2-x1);
+                       }
+                       else {
+                               if(rf->xmin<x1) rf->xmin= x1;
+                               newrct= stack+ *count;
+                               (*count)++;
+
+                               newrct->xmin= x1;
+                               newrct->xmax= rf->xmax-(x2-x1);
+                               newrct->ymin= rf->ymin;
+                               newrct->ymax= rf->ymax;
+
+                               if(newrct->xmin==newrct->xmax) (*count)--;
+
+                               rf->xmax= x2;
+                       }
+               }
+               rf++;
+       }
+
+}
+
+static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
+{
+       rctf *rf, *newrct;
+       short a;
+
+       a= *count;
+       rf= stack;
+       for(;a>0;a--) {
+               if(rf->ymin<y1) {
+                       if(rf->ymax<y1) {
+                               rf->ymin+= (y2-y1);
+                               rf->ymax+= (y2-y1);
+                       }
+                       else {
+                               if(rf->ymax>y2) rf->ymax= y2;
+                               newrct= stack+ *count;
+                               (*count)++;
+
+                               newrct->ymax= y2;
+                               newrct->ymin= rf->ymin+(y2-y1);
+                               newrct->xmin= rf->xmin;
+                               newrct->xmax= rf->xmax;
+
+                               if(newrct->ymin==newrct->ymax) (*count)--;
+
+                               rf->ymin= y1;
+                       }
+               }
+               else if(rf->ymax>y2) {
+                       if(rf->ymin>y2) {
+                               rf->ymin-= (y2-y1);
+                               rf->ymax-= (y2-y1);
+                       }
+                       else {
+                               if(rf->ymin<y1) rf->ymin= y1;
+                               newrct= stack+ *count;
+                               (*count)++;
+
+                               newrct->ymin= y1;
+                               newrct->ymax= rf->ymax-(y2-y1);
+                               newrct->xmin= rf->xmin;
+                               newrct->xmax= rf->xmax;
+
+                               if(newrct->ymin==newrct->ymax) (*count)--;
+
+                               rf->ymax= y2;
+                       }
+               }
+               rf++;
+       }
+}
+
+static float square_rctf(rctf *rf)
+{
+       float x, y;
+
+       x= rf->xmax- rf->xmin;
+       y= rf->ymax- rf->ymin;
+       return (x*y);
+}
+
+static float clipx_rctf(rctf *rf, float x1, float x2)
+{
+       float size;
+
+       size= rf->xmax - rf->xmin;
+
+       if(rf->xmin<x1) {
+               rf->xmin= x1;
+       }
+       if(rf->xmax>x2) {
+               rf->xmax= x2;
+       }
+       if(rf->xmin > rf->xmax) {
+               rf->xmin = rf->xmax;
+               return 0.0;
+       }
+       else if(size!=0.0) {
+               return (rf->xmax - rf->xmin)/size;
+       }
+       return 1.0;
+}
+
+static float clipy_rctf(rctf *rf, float y1, float y2)
+{
+       float size;
+
+       size= rf->ymax - rf->ymin;
+
+       if(rf->ymin<y1) {
+               rf->ymin= y1;
+       }
+       if(rf->ymax>y2) {
+               rf->ymax= y2;
+       }
+
+       if(rf->ymin > rf->ymax) {
+               rf->ymin = rf->ymax;
+               return 0.0;
+       }
+       else if(size!=0.0) {
+               return (rf->ymax - rf->ymin)/size;
+       }
+       return 1.0;
+
+}
+
+static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
+{
+       /* sample box, is clipped already, and minx etc. have been set at ibuf size.
+       Enlarge with antialiased edges of the pixels */
+
+       float muly,mulx,div;
+       int ofs;
+       int x, y, startx, endx, starty, endy;
+       char *rect;
+
+       startx= (int)floor(rf->xmin);
+       endx= (int)floor(rf->xmax);
+       starty= (int)floor(rf->ymin);
+       endy= (int)floor(rf->ymax);
+
+       if(startx < 0) startx= 0;
+       if(starty < 0) starty= 0;
+       if(endx>=ibuf->x) endx= ibuf->x-1;
+       if(endy>=ibuf->y) endy= ibuf->y-1;
+
+       if(starty==endy && startx==endx) {
+
+               ofs = starty*ibuf->x + startx;
+               rect = (char *)(ibuf->rect +ofs);
+               texres->tr= ((float)rect[0])/255.0f;
+               texres->tg= ((float)rect[1])/255.0f;
+               texres->tb= ((float)rect[2])/255.0f;
+                       /* alpha has been set in function imagewraposa() */
+               if(texres->talpha) {
+                       texres->ta= ((float)rect[3])/255.0f;
+               }
+       }
+       else {
+               div= texres->tr= texres->tg= texres->tb= texres->ta= 0.0;
+               for(y=starty;y<=endy;y++) {
+                       ofs = y*ibuf->x +startx;
+                       rect = (char *)(ibuf->rect+ofs);
+
+                       muly= 1.0;
+
+                       if(starty==endy);
+                       else {
+                               if(y==starty) muly= 1.0f-(rf->ymin - y);
+                               if(y==endy) muly= (rf->ymax - y);
+                       }
+                       if(startx==endx) {
+                               mulx= muly;
+                               if(texres->talpha) texres->ta+= mulx*rect[3];
+                               texres->tr+= mulx*rect[0];
+                               texres->tg+= mulx*rect[1];
+                               texres->tb+= mulx*rect[2];
+                               div+= mulx;
+                       }
+                       else {
+                               for(x=startx;x<=endx;x++) {
+                                       mulx= muly;
+                                       if(x==startx) mulx*= 1.0f-(rf->xmin - x);
+                                       if(x==endx) mulx*= (rf->xmax - x);
+
+                                       if(mulx==1.0) {
+                                               if(texres->talpha) texres->ta+= rect[3];
+                                               texres->tr+= rect[0];
+                                               texres->tg+= rect[1];
+                                               texres->tb+= rect[2];
+                                               div+= 1.0;
+                                       }
+                                       else {
+                                               if(texres->talpha) texres->ta+= mulx*rect[3];
+                                               texres->tr+= mulx*rect[0];
+                                               texres->tg+= mulx*rect[1];
+                                               texres->tb+= mulx*rect[2];
+                                               div+= mulx;
+                                       }
+                                       rect+=4;
+                               }
+                       }
+               }
+               if(div!=0.0) {
+                       div*= 255.0;
+       
+                       texres->tb/= div;
+                       texres->tg/= div;
+                       texres->tr/= div;
+                       
+                       if(texres->talpha) texres->ta/= div;
+               }
+               else {
+                       texres->tr= texres->tg= texres->tb= texres->ta= 0.0;
+               }
+       }
+}
+
+static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres)
+{
+       /* Sample box, performs clip. minx etc are in range 0.0 - 1.0 .
+     * Enlarge with antialiased edges of pixels.
+     * If global variable 'imaprepeat' has been set, the
+     *  clipped-away parts are sampled as well.
+     */
+       TexResult texr;
+       rctf *rf, stack[8];
+       float opp, tot, alphaclip= 1.0;
+       short count=1;
+
+       rf= stack;
+       rf->xmin= minx*(ibuf->x);
+       rf->xmax= maxx*(ibuf->x);
+       rf->ymin= miny*(ibuf->y);
+       rf->ymax= maxy*(ibuf->y);
+
+       if(imapextend);
+       else if(imaprepeat) clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
+       else {
+               alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x));
+
+               if(alphaclip<=0.0) {
+                       texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
+                       return;
+               }
+       }
+
+       if(imapextend);
+       else if(imaprepeat) clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
+       else {
+               alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y));
+
+               if(alphaclip<=0.0) {
+                       texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
+                       return;
+               }
+       }
+
+       if(count>1) {
+               tot= texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
+               while(count--) {
+                       boxsampleclip(ibuf, rf, &texr);
+                       
+                       opp= square_rctf(rf);
+                       tot+= opp;
+
+                       texres->tr+= opp*texr.tr;
+                       texres->tg+= opp*texr.tg;
+                       texres->tb+= opp*texr.tb;
+                       if(texres->talpha) texres->ta+= opp*texr.ta;
+                       rf++;
+               }
+               if(tot!= 0.0) {
+                       texres->tr/= tot;
+                       texres->tg/= tot;
+                       texres->tb/= tot;
+                       if(texres->talpha) texres->ta/= tot;
+               }
+       }
+       else {
+               boxsampleclip(ibuf, rf, texres);
+       }
+
+       if(texres->talpha==0) texres->ta= 1.0;
+       
+       if(alphaclip!=1.0) {
+               /* this is for laetr investigation, premul or not? */
+               /* texres->tr*= alphaclip; */
+               /* texres->tg*= alphaclip; */
+               /* texres->tb*= alphaclip; */
+               texres->ta*= alphaclip;
+       }
+}      
+
+static void makemipmap(Image *ima)
+{
+       struct ImBuf *ibuf;
+       int minsize, curmap=0;
+       
+       ibuf= ima->ibuf;
+       minsize= MIN2(ibuf->x, ibuf->y);
+       
+       while(minsize>3 && curmap<BLI_ARRAY_NELEMS(ima->mipmap)) {
+               
+               ibuf= IMB_dupImBuf(ibuf);
+               IMB_filter(ibuf);
+               ima->mipmap[curmap]= (struct ImBuf *)IMB_onehalf(ibuf);
+               IMB_freeImBuf(ibuf);
+               ibuf= ima->mipmap[curmap];
+               
+               curmap++;
+               minsize= MIN2(ibuf->x, ibuf->y);
+       }
+}
+
+
+int imagewraposa(Tex *tex, float *texvec, float *dxt, float *dyt, TexResult *texres)
+{
+       extern SDL_mutex *load_ibuf_lock; // initrender.c
+       TexResult texr;
+       Image *ima;
+       ImBuf *ibuf, *previbuf;
+       float fx, fy, minx, maxx, miny, maxy, dx, dy;
+       float maxd, pixsize, val1, val2, val3;
+       int curmap;
+
+       
+       ima= tex->ima;
+
+       texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0;
+
+       if(ima==NULL || ima->ok== 0) {
+               return 0;
+       }
+       
+       if(ima->ibuf==NULL) {
+               if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock);
+               if(ima->ibuf==NULL) ima_ibuf_is_nul(tex);
+               if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock);
+       }
+       
+       if (ima->ok) {
+       
+               if(tex->imaflag & TEX_MIPMAP) {
+                       if(ima->mipmap[0]==NULL) {
+                               if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock);
+                               if(ima->mipmap[0]==NULL) makemipmap(ima);
+                               if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock);
+                       }
+               }
+       
+               ibuf = ima->ibuf;
+               
+               if(tex->imaflag & TEX_USEALPHA) {
+                       if(tex->imaflag & TEX_CALCALPHA);
+                       else texres->talpha= 1;
+               }
+               
+               texr.talpha= texres->talpha;
+               
+               if(tex->imaflag & TEX_IMAROT) {
+                       fy= texvec[0];
+                       fx= texvec[1];
+               }
+               else {
+                       fx= texvec[0];
+                       fy= texvec[1];
+               }
+               
+               if(ibuf->flags & IB_fields) {
+                       if(R.r.mode & R_FIELDS) {                       /* field render */
+                               if(R.flag & R_SEC_FIELD) {              /* correction for 2nd field */
+                                       /* fac1= 0.5/( (float)ibuf->y ); */
+                                       /* fy-= fac1; */
+                               }
+                               else {                          /* first field */
+                                       fy+= 0.5f/( (float)ibuf->y );
+                               }
+                       }
+               }
+               
+               /* pixel coordinates */
+
+               minx= MIN3(dxt[0],dyt[0],dxt[0]+dyt[0] );
+               maxx= MAX3(dxt[0],dyt[0],dxt[0]+dyt[0] );
+               miny= MIN3(dxt[1],dyt[1],dxt[1]+dyt[1] );
+               maxy= MAX3(dxt[1],dyt[1],dxt[1]+dyt[1] );
+
+               /* tex_sharper has been removed */
+
+               minx= tex->filtersize*(maxx-minx)/2.0f;
+               miny= tex->filtersize*(maxy-miny)/2.0f;
+               
+               if(tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny);
+               
+               if(minx>0.25) minx= 0.25;
+               else if(minx<0.00001f) minx= 0.00001f;  /* side faces of unit-cube */
+               if(miny>0.25) miny= 0.25;
+               else if(miny<0.00001f) miny= 0.00001f;
+
+               
+               /* repeat and clip */
+               
+               /* watch it: imaprepeat is global value (see boxsample) */
+               imaprepeat= (tex->extend==TEX_REPEAT);
+               imapextend= (tex->extend==TEX_EXTEND);
+
+               if(tex->extend == TEX_CHECKER) {
+                       int xs, ys, xs1, ys1, xs2, ys2, boundary;
+                       
+                       xs= (int)floor(fx);
+                       ys= (int)floor(fy);
+                       
+                       // both checkers available, no boundary exceptions, checkerdist will eat aliasing
+                       if( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) {
+                               fx-= xs;
+                               fy-= ys;
+                       }
+                       else {
+                               
+                               xs1= (int)floor(fx-minx);
+                               ys1= (int)floor(fy-miny);
+                               xs2= (int)floor(fx+minx);
+                               ys2= (int)floor(fy+miny);
+                               boundary= (xs1!=xs2) || (ys1!=ys2);
+       
+                               if(boundary==0) {
+                                       if( (tex->flag & TEX_CHECKER_ODD)==0) {
+                                               if((xs+ys) & 1); 
+                                               else return 0;
+                                       }
+                                       if( (tex->flag & TEX_CHECKER_EVEN)==0) {
+                                               if((xs+ys) & 1) return 0;
+                                       }
+                                       fx-= xs;
+                                       fy-= ys;
+                               }
+                               else {
+                                       if(tex->flag & TEX_CHECKER_ODD) {
+                                               if((xs1+ys) & 1) fx-= xs2;
+                                               else fx-= xs1;
+                                               
+                                               if((ys1+xs) & 1) fy-= ys2;
+                                               else fy-= ys1;
+                                       }
+                                       if(tex->flag & TEX_CHECKER_EVEN) {
+                                               if((xs1+ys) & 1) fx-= xs1;
+                                               else fx-= xs2;
+                                               
+                                               if((ys1+xs) & 1) fy-= ys1;
+                                               else fy-= ys2;
+                                       }
+                               }
+                       }
+
+                       /* scale around center, (0.5, 0.5) */
+                       if(tex->checkerdist<1.0) {
+                               fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5;
+                               fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5;
+                               minx/= (1.0-tex->checkerdist);
+                               miny/= (1.0-tex->checkerdist);
+                       }
+               }
+
+               if(tex->extend == TEX_CLIPCUBE) {
+                       if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0 || texvec[2]<-1.0 || texvec[2]>1.0) {
+                               return 0;
+                       }
+               }
+               else if(tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
+                       if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0) {
+                               return 0;
+                       }
+               }
+               else {
+                       if(tex->extend==TEX_EXTEND) {
+                               if(fx>1.0) fx = 1.0;
+                               else if(fx<0.0) fx= 0.0;
+                       }
+                       else {
+                               if(fx>1.0) fx -= (int)(fx);
+                               else if(fx<0.0) fx+= 1-(int)(fx);
+                       }
+                       
+                       if(tex->extend==TEX_EXTEND) {
+                               if(fy>1.0) fy = 1.0;
+                               else if(fy<0.0) fy= 0.0;
+                       }
+                       else {
+                               if(fy>1.0) fy -= (int)(fy);
+                               else if(fy<0.0) fy+= 1-(int)(fy);
+                       }
+               }
+       
+               /* warning no return! */
+               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
+                       ibuf->rect+= (ibuf->x*ibuf->y);
+               }
+
+               /* choice:  */
+               if(tex->imaflag & TEX_MIPMAP) {
+                       
+                       dx= minx;
+                       dy= miny;
+                       maxd= MAX2(dx, dy);
+                       if(maxd>0.5) maxd= 0.5;
+
+                       pixsize = 1.0f/ (float) MIN2(ibuf->x, ibuf->y);
+                       
+                       curmap= 0;
+                       previbuf= ibuf;
+                       while(curmap<BLI_ARRAY_NELEMS(ima->mipmap) && ima->mipmap[curmap]) {
+                               if(maxd < pixsize) break;
+                               previbuf= ibuf;
+                               ibuf= ima->mipmap[curmap];
+                               pixsize= 1.0f / (float)MIN2(ibuf->x, ibuf->y); /* this used to be 1.0 */                
+                               curmap++;
+                       }
+                       
+                       if(previbuf!=ibuf || (tex->imaflag & TEX_INTERPOL)) {
+                               /* sample at least 1 pixel */
+                               if (minx < 0.5f / ima->ibuf->x) minx = 0.5f / ima->ibuf->x;
+                               if (miny < 0.5f / ima->ibuf->y) miny = 0.5f / ima->ibuf->y;
+                       }
+                       
+                       if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
+                               /* a bit extra filter */
+                               minx*= 1.35f;
+                               miny*= 1.35f;
+                               
+                               boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, texres);
+                               val1= texres->tr+texres->tg+texres->tb;
+                               boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
+                               val2= texr.tr + texr.tg + texr.tb;
+                               boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &texr);
+                               val3= texr.tr + texr.tg + texr.tb;
+       
+                               if(previbuf!=ibuf) {  /* interpolate */
+                                       
+                                       boxsample(previbuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, &texr);
+                                       
+                                       /* calc rgb */
+                                       dx= 2.0f*(pixsize-maxd)/pixsize;
+                                       if(dx>=1.0f) {
+                                               texres->ta= texr.ta; texres->tb= texr.tb;
+                                               texres->tg= texr.tg; texres->tr= texr.tr;
+                                       }
+                                       else {
+                                               dy= 1.0f-dx;
+                                               texres->tb= dy*texres->tb+ dx*texr.tb;
+                                               texres->tg= dy*texres->tg+ dx*texr.tg;
+                                               texres->tr= dy*texres->tr+ dx*texr.tr;
+                                               texres->ta= dy*texres->ta+ dx*texr.ta;
+                                       }
+                                       
+                                       val1= dy*val1+ dx*(texr.tr + texr.tg + texr.tb);
+                                       boxsample(previbuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
+                                       val2= dy*val2+ dx*(texr.tr + texr.tg + texr.tb);
+                                       boxsample(previbuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &texr);
+                                       val3= dy*val3+ dx*(texr.tr + texr.tg + texr.tb);
+                               }
+
+                               /* don't switch x or y! */
+                               texres->nor[0]= (val1-val2);
+                               texres->nor[1]= (val1-val3);
+                       }
+                       else {
+                               maxx= fx+minx;
+                               minx= fx-minx;
+                               maxy= fy+miny;
+                               miny= fy-miny;
+       
+                               boxsample(ibuf, minx, miny, maxx, maxy, texres);
+       
+                               if(previbuf!=ibuf) {  /* interpolate */
+                                       boxsample(previbuf, minx, miny, maxx, maxy, &texr);
+                                       
+                                       fx= 2.0f*(pixsize-maxd)/pixsize;
+                                       
+                                       if(fx>=1.0) {
+                                               texres->ta= texr.ta; texres->tb= texr.tb;
+                                               texres->tg= texr.tg; texres->tr= texr.tr;
+                                       } else {
+                                               fy= 1.0f-fx;
+                                               texres->tb= fy*texres->tb+ fx*texr.tb;
+                                               texres->tg= fy*texres->tg+ fx*texr.tg;
+                                               texres->tr= fy*texres->tr+ fx*texr.tr;
+                                               texres->ta= fy*texres->ta+ fx*texr.ta;
+                                       }
+                               }
+                       }
+               }
+               else {
+                       if((tex->imaflag & TEX_INTERPOL)) {
+                               /* sample 1 pixel minimum */
+                               if (minx < 0.5f / ima->ibuf->x) minx = 0.5f / ima->ibuf->x;
+                               if (miny < 0.5f / ima->ibuf->y) miny = 0.5f / ima->ibuf->y;
+                       }
+
+                       if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
+                               
+                               /* a bit extra filter */
+                               minx*= 1.35f;
+                               miny*= 1.35f;
+                               
+                               boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, texres);
+                               val1= texres->tr+texres->tg+texres->tb;
+
+                               boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
+                               val2= texr.tr + texr.tg + texr.tb;
+                               
+                               boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+miny, fy+2.0f*miny, &texr);
+                               val3= texr.tr + texr.tg + texr.tb;
+
+                               /* don't switch x or y! */
+                               texres->nor[0]= (val1-val2);
+                               texres->nor[1]= (val1-val3);
+                       }
+                       else {
+                               boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres);
+                       }
+               }
+               
+               BRICONTRGB;
+               
+               if(tex->imaflag & TEX_CALCALPHA) {
+                       texres->ta= texres->tin= texres->ta*MAX3(texres->tr, texres->tg, texres->tb);
+               }
+               else texres->tin= texres->ta;
+
+               if(tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
+               
+               if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
+                       ibuf->rect-= (ibuf->x*ibuf->y);
+               }
+
+               if(texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
+                       texres->nor[0]= 0.5-texres->tr;
+                       texres->nor[1]= 0.5-texres->tg;
+                       texres->nor[2]= -texres->tb;
+               }
+       }
+       else {
+               texres->tin= 0.0f;
+               return 0;
+       }
+       
+       if(texres->nor) return 3;
+       else return 1;
+}
index be1f659d7e6cae437c42667698a6eef7f116b84a..b4edee17bb62c8757bdce1b86140975cf6c1cf96 100644 (file)
 #include "quicktime_export.h"
 #endif
 
+#include "SDL_thread.h"
+
 /* this module */
 #include "render.h"
-#include "render_intern.h"
 
 #include "RE_callbacks.h"
 #include "zbuf.h"
 #include "rendercore.h" /* part handler for the old renderer, shading functions */
+#include "pixelshading.h"
 #include "renderPreAndPost.h"
 #include "vanillaRenderPipe.h"
 #include "renderHelp.h"
 #include "jitter.h"
+#include "gammaCorrectionTables.h"
 
 /* Own includes */
 #include "initrender.h"
 /* yafray: include for yafray export/render */
 #include "YafRay_Api.h"
 
-/* Some crud :/ */
-#define ELEM3(a, b, c, d)       ( ELEM(a, b, c) || (a)==(d) )
-
 
-/* from render.c */
-extern float fmask[256], centLut[16], *fmask1[9], *fmask2[9];
-extern unsigned short *mask1[9], *mask2[9], *igamtab2;
-extern char cmask[256], *centmask;
+float centLut[16], *fmask1[9], *fmask2[9];
+unsigned short *gamtab, *igamtab2, *igamtab1;
+char cmask[256], *centmask;
 
 Material defmaterial;
-short pa; /* pa is global part, for print */
-short allparts[65][4];
-int qscount;
-
-/* ********************* *********************** */
-
-
-void init_def_material(void)
-{
-       Material *ma;
-
-       ma= &defmaterial;
-       
-       init_material(&defmaterial);
-
-       init_render_material(ma);
-}
-
-void RE_init_render_data(void)
-{
-       memset(&R, 0, sizeof(RE_Render));
-       memset(&O, 0, sizeof(Osa));
-       O.dxwin[0]= 1.0;
-       O.dywin[1]= 1.0;
-       
-       R.blove= (VertRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blove");
-       R.blovl= (VlakRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blovl");
-       R.bloha= (HaloRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Bloha");
-       R.la= (LampRen **)MEM_mallocN(LAMPINITSIZE*sizeof(void *),"renderlamparray");
-
-       init_def_material();
-}
-
-void RE_free_render_data()
-{
-       MEM_freeN(R.blove);
-       R.blove= 0;
-       MEM_freeN(R.blovl);
-       R.blovl= 0;
-       MEM_freeN(R.bloha);
-       R.bloha= 0;
-       MEM_freeN(R.la);
-       R.la= 0;
-       if(R.rectot) MEM_freeN(R.rectot);
-       if(R.rectz) MEM_freeN(R.rectz);
-       if(R.rectspare) MEM_freeN(R.rectspare);
-       R.rectot= 0;
-       R.rectz= 0;
-       R.rectspare= 0;
-
-       end_render_material(&defmaterial);
-}
 
 /* ****************** GAMMA, MASKS and LUTS **************** */
 
-float  calc_weight(float *weight, int i, int j)
+static float calc_weight(float *weight, int i, int j)
 {
        float x, y, dist, totw= 0.0, fac;
        int a;
@@ -201,23 +148,20 @@ float  calc_weight(float *weight, int i, int j)
        return totw;
 }
 
-void RE_init_filt_mask(void)
+static void init_filt_mask(void)
 {
        static int firsttime=1;
        static int lastosa=0;
        static int lastgauss=0;
        static float lastgamma= 0.0;
-       float gamma, igamma, flweight[32];
+       float gamma, igamma, flweight[32], fmask[256];
        float weight[32], totw, val, *fpx1, *fpx2, *fpy1, *fpy2, *m3, *m4;
        int i, j, a;
-       unsigned short *m1, *m2, shweight[32];
 
        if(firsttime) {
                firsttime= 0;
                
                for(a=0; a<9;a++) {
-                       mask1[a]= MEM_mallocN(256*sizeof(short), "initfilt");
-                       mask2[a]= MEM_mallocN(256*sizeof(short), "initfilt");
                        fmask1[a]= MEM_mallocN(256*sizeof(float), "initfilt");
                        fmask2[a]= MEM_mallocN(256*sizeof(float), "initfilt");
                }
@@ -294,10 +238,8 @@ void RE_init_filt_mask(void)
                }
 
                for(a=0; a<9;a++) {
-                       memset(mask1[a], 0, 256*2);
-                       memset(mask2[a], 0, 256*2);
-                       memset(fmask1[a], 0, 256*4);
-                       memset(fmask2[a], 0, 256*4);
+                       memset(fmask1[a], 0, 256*sizeof(float));
+                       memset(fmask2[a], 0, 256*sizeof(float));
                }
 
                /* calculate totw */
@@ -315,60 +257,41 @@ void RE_init_filt_mask(void)
                                memset(weight, 0, sizeof(weight));
                                calc_weight(weight, i, j);
 
-                               for(a=0; a<16; a++) shweight[a]= weight[a]*(65535.0/totw);
                                for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0/totw);
 
-                               m1= mask1[ 3*(j+1)+i+1 ];
-                               m2= mask2[ 3*(j+1)+i+1 ];
                                m3= fmask1[ 3*(j+1)+i+1 ];
                                m4= fmask2[ 3*(j+1)+i+1 ];
 
                                for(a=0; a<256; a++) {
                                        if(a &   1) {
-                                               m1[a]+= shweight[0];
-                                               m2[a]+= shweight[8];
                                                m3[a]+= flweight[0];
                                                m4[a]+= flweight[8];
                                        }
                                        if(a &   2) {
-                                               m1[a]+= shweight[1];
-                                               m2[a]+= shweight[9];
                                                m3[a]+= flweight[1];
                                                m4[a]+= flweight[9];
                                        }
                                        if(a &   4) {
-                                               m1[a]+= shweight[2];
-                                               m2[a]+= shweight[10];
                                                m3[a]+= flweight[2];
                                                m4[a]+= flweight[10];
                                        }
                                        if(a &   8) {
-                                               m1[a]+= shweight[3];
-                                               m2[a]+= shweight[11];
                                                m3[a]+= flweight[3];
                                                m4[a]+= flweight[11];
                                        }
                                        if(a &  16) {
-                                               m1[a]+= shweight[4];
-                                               m2[a]+= shweight[12];
                                                m3[a]+= flweight[4];
                                                m4[a]+= flweight[12];
                                        }
                                        if(a &  32) {
-                                               m1[a]+= shweight[5];
-                                               m2[a]+= shweight[13];
                                                m3[a]+= flweight[5];
                                                m4[a]+= flweight[13];
                                        }
                                        if(a &  64) {
-                                               m1[a]+= shweight[6];
-                                               m2[a]+= shweight[14];
                                                m3[a]+= flweight[6];
                                                m4[a]+= flweight[14];
                                        }
                                        if(a & 128) {
-                                               m1[a]+= shweight[7];
-                                               m2[a]+= shweight[15];
                                                m3[a]+= flweight[7];
                                                m4[a]+= flweight[15];
                                        }
@@ -452,13 +375,11 @@ void RE_init_filt_mask(void)
        }
 }
 
-void RE_free_filt_mask()
+static void free_filt_mask()
 {
        int a;
 
        for(a=0; a<9; a++) {
-               MEM_freeN(mask1[a]);
-               MEM_freeN(mask2[a]);
                MEM_freeN(fmask1[a]);
                MEM_freeN(fmask2[a]);
        }
@@ -469,9 +390,9 @@ void RE_free_filt_mask()
        MEM_freeN(centmask);
 }
 
-/* add stuff */
-
+/* unused */
 
+#if 0
 void defaultlamp()
 {
        LampRen *lar;
@@ -489,8 +410,60 @@ void defaultlamp()
        lar->b= 1.0;
        lar->lay= 65535;
 }
+#endif
+
+
+
+/* ********************* init calls *********************** */
 
 
+static void init_def_material(void)
+{
+       Material *ma;
+       
+       ma= &defmaterial;
+       
+       init_material(&defmaterial);
+       
+       init_render_material(ma);
+}
+
+void RE_init_render_data(void)
+{
+       memset(&R, 0, sizeof(RE_Render));
+       
+       R.blove= (VertRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blove");
+       R.blovl= (VlakRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blovl");
+       R.bloha= (HaloRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Bloha");
+       R.la= (LampRen **)MEM_mallocN(LAMPINITSIZE*sizeof(void *),"renderlamparray");
+       
+       init_def_material();
+       init_filt_mask();
+}
+
+void RE_free_render_data()
+{
+       MEM_freeN(R.blove);
+       R.blove= NULL;
+       MEM_freeN(R.blovl);
+       R.blovl= NULL;
+       MEM_freeN(R.bloha);
+       R.bloha= NULL;
+       MEM_freeN(R.la);
+       R.la= NULL;
+       if(R.rectot) MEM_freeN(R.rectot);
+       if(R.rectftot) MEM_freeN(R.rectftot);
+       if(R.rectz) MEM_freeN(R.rectz);
+       if(R.rectspare) MEM_freeN(R.rectspare);
+       R.rectot= NULL;
+       R.rectftot= NULL;
+       R.rectz= NULL;
+       R.rectspare= NULL;
+       
+       end_render_material(&defmaterial);
+       free_filt_mask();
+}
+
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 
 void RE_make_existing_file(char *name)
@@ -601,13 +574,41 @@ void RE_setwindowclip(int mode, int jmode)
 
 /* ~~~~~~~~~~~~~~~~ PARTS ~~~~~~~~~~~~~~~~~~~~~~ */
 
-#define PART_EMPTY     -2
+/** 
+* Part as in part-rendering. An image rendered in parts is rendered
+* to a list of parts, with x,y size, and a pointer to the render
+* output stored per part. Internal!
+*/
+typedef struct Part
+{
+       struct Part *next, *prev;
+       unsigned int *rect;             // color 4x8 bits
+       float *rectf;                   // color 4x32 bits
+       unsigned int *rectz;    // zbuffer
+
+       short minx, miny, maxx, maxy, x, y;
+} Part;
+
+static void freeparts(void)
+{
+       Part *part= R.parts.first;
+       while(part) {
+               if(part->rect) MEM_freeN(part->rect);
+               if(part->rectz) MEM_freeN(part->rectz);
+               if(part->rectf) MEM_freeN(part->rectf);
+               part= part->next;
+       }
+       BLI_freelistN(&R.parts);
+}
 
-void initparts()
+static void initparts(void)
 {
+       Part *pa;
        short nr, xd, yd, xpart, ypart, xparts, yparts;
        short a, xminb, xmaxb, yminb, ymaxb;
 
+       freeparts();
+       
        if(R.r.mode & R_BORDER) {
                xminb= R.r.border.xmin*R.rectx;
                xmaxb= R.r.border.xmax*R.rectx;
@@ -629,9 +630,6 @@ void initparts()
        xparts= R.r.xparts;     /* for border */
        yparts= R.r.yparts;
 
-       for(nr=0;nr<xparts*yparts;nr++)
-               allparts[nr][0]= PART_EMPTY;    /* clear array */
-
        xpart= R.rectx/xparts;
        ypart= R.recty/yparts;
 
@@ -645,82 +643,108 @@ void initparts()
                xpart= (xmaxb-xminb)/xparts;
                ypart= (ymaxb-yminb)/yparts;
        }
-
+       
        for(nr=0; nr<xparts*yparts; nr++) {
-
+               pa= MEM_callocN(sizeof(Part), "new part");
+               
                if(R.r.mode & R_PANORAMA) {
-                       allparts[nr][0]= 0;
-                       allparts[nr][1]= 0;
-                       allparts[nr][2]= R.rectx;
-                       allparts[nr][3]= R.recty;
+                       pa->minx= pa->miny= 0;
+                       pa->maxx= pa->x= R.rectx;
+                       pa->maxy= pa->y= R.recty;
                }
                else {
                        xd= (nr % xparts);
                        yd= (nr-xd)/xparts;
 
-                       allparts[nr][0]= xminb+ xd*xpart;
-                       allparts[nr][1]= yminb+ yd*ypart;
-                       if(xd<R.r.xparts-1) allparts[nr][2]= allparts[nr][0]+xpart;
-                       else allparts[nr][2]= xmaxb;
-                       if(yd<R.r.yparts-1) allparts[nr][3]= allparts[nr][1]+ypart;
-                       else allparts[nr][3]= ymaxb;
+                       pa->minx= xminb+ xd*xpart;
+                       pa->miny= yminb+ yd*ypart;
+                       if(xd<R.r.xparts-1) pa->maxx= pa->minx+xpart;
+                       else pa->maxx= xmaxb;
+                       if(yd<R.r.yparts-1) pa->maxy= pa->miny+ypart;
+                       else pa->maxy= ymaxb;
 
-                       if(allparts[nr][2]-allparts[nr][0]<=0) allparts[nr][0]= PART_EMPTY;
-                       if(allparts[nr][3]-allparts[nr][1]<=0) allparts[nr][0]= PART_EMPTY;
-                       
-                       /* gauss needs 1 pixel extra to work */
+                       pa->x= pa->maxx-pa->minx;
+                       pa->y= pa->maxy-pa->miny;
+               }
+               
+               if(pa->x>0 && pa->y>0) {
+                       /* Gauss needs 1 pixel extra to work */
                        if(xparts*yparts>1 && (R.r.mode & R_GAUSS)) {
-                               allparts[nr][0]-= 1;
-                               allparts[nr][1]-= 1;
-                               allparts[nr][2]+= 1;
-                               allparts[nr][3]+= 1;
+                               pa->minx-= 1;
+                               pa->miny-= 1;
+                               pa->maxx+= 1;
+                               pa->maxy+= 1;
+                               pa->x+= 2;
+                               pa->y+= 2;
                        }
+                       BLI_addtail(&R.parts, pa);
                }
+               else MEM_freeN(pa);
        }
        
 }
 
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-short setpart(short nr)        /* return 0 if incorrect part */
+static void setpart(Part *pa)
 {
 
-       if(allparts[nr][0]== PART_EMPTY) return 0;
-
-       R.xstart= allparts[nr][0]-R.afmx;
-       R.ystart= allparts[nr][1]-R.afmy;
-       R.xend= allparts[nr][2]-R.afmx;
-       R.yend= allparts[nr][3]-R.afmy;
-       R.rectx= R.xend-R.xstart;
-       R.recty= R.yend-R.ystart;
-
-       return 1;
+       R.xstart= pa->minx-R.afmx;
+       R.ystart= pa->miny-R.afmy;
+       R.xend= pa->maxx-R.afmx;
+       R.yend= pa->maxy-R.afmy;
+       R.rectx= pa->x;
+       R.recty= pa->y;
 }
 
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-void addparttorect(short nr, Part *part)
+static void addparttorect(Part *pa)
 {
-       unsigned int *rt, *rp;
+       float *rf, *rfp;
+       unsigned int *rt, *rtp, *rz, *rzp;
        int y, heigth, len, copylen;
 
-       /* the right offset in rectot */
+       /* calc the right offset in rects, zbuffer cannot exist... */
 
-       rp= part->rect;
-       copylen=len= (allparts[nr][2]-allparts[nr][0]);
-       heigth= (allparts[nr][3]-allparts[nr][1]);
+       rtp= pa->rect;
+       rzp= pa->rectz;
+       rfp= pa->rectf;
+       
+       copylen=len= pa->x;
+       heigth= pa->y;
        
        if(R.r.mode & R_GAUSS) {
-               rp+= 1+len;
+               
+               rtp+= 1+len;
+               if(rzp) rzp+= 1+len;
+               if(rfp) rfp+= 4*(1+len);
+               
                copylen= len-2;
                heigth -= 2;
-               rt= R.rectot+ (allparts[nr][1] + 1)*R.rectx+ (allparts[nr][0]+1);
+               rt= R.rectot+ (pa->miny + 1)*R.rectx+ (pa->minx+1);
+               rz= R.rectz+ (pa->miny + 1)*R.rectx+ (pa->minx+1);
+               rf= R.rectftot+ 4*( (pa->miny + 1)*R.rectx + (pa->minx+1) );
+       }
+       else {
+               rt= R.rectot+ pa->miny*R.rectx+ pa->minx;
+               rz= R.rectz+ pa->miny*R.rectx+ pa->minx;
+               rf= R.rectftot+ 4*(pa->miny*R.rectx+ pa->minx);
        }
-       else rt= R.rectot+ allparts[nr][1]*R.rectx+ allparts[nr][0];
-
 
        for(y=0; y<heigth; y++) {
-               memcpy(rt, rp, 4*copylen);
+               memcpy(rt, rtp, 4*copylen);
                rt+= R.rectx;
-               rp+= len;
+               rtp+= len;
+               
+               if(rzp) {
+                       memcpy(rz, rzp, 4*copylen);
+                       rz+= R.rectx;
+                       rzp+= len;
+               }
+               if(rfp) {
+                       memcpy(rf, rfp, 16*copylen);
+                       rf+= 4*R.rectx;
+                       rfp+= 4*len;
+               }
        }
 }
 
@@ -728,7 +752,7 @@ void addparttorect(short nr, Part *part)
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 
  
-void add_to_blurbuf(int blur)
+static void add_to_blurbuf(int blur)
 {
        static unsigned int *blurrect= 0;
        int tot, gamval;
@@ -797,7 +821,7 @@ void yafrayRender()
        R.flag |= R_RENDERING;  /* !!! */
 
        if (R.rectz) MEM_freeN(R.rectz);
-       R.rectz = 0;
+       R.rectz = NULL;
 
        // switch must be done before prepareScene()
        if (!R.r.YFexportxml)
@@ -815,39 +839,70 @@ void yafrayRender()
 
 
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-void render() {
-       /* yafray: render, see above */
-       if (R.r.renderer==R_YAFRAY)
-               yafrayRender();
-       else
-               oldRenderLoop();
-}
+
+// exported to other files, belongs in include... later
+SDL_mutex *render_abuf_lock=NULL, *load_ibuf_lock=NULL;
 
 
-void oldRenderLoop(void)  /* here the PART and FIELD loops */
+static void renderloop_setblending(void)
 {
-       Part *part;
-       unsigned int *rt, *rt1, *rt2;
-       int len, y;
-       short blur, a,fields,fi,parts;  /* pa is a global because of print */
+       
+       /* this value should only be set here. do_gamma is for gammablended adding of subpixels */
+       do_gamma= 0;
+       if(R.r.mode & R_GAMMA) {
+               if((R.r.mode & R_OSA)) do_gamma= 1;
+       }
+       
+       /* always call, it does gamma tables used by alphaunder, but call after R.osa and jit was set */
+       init_filt_mask();
+       
+       switch (R.r.alphamode) {
+               case R_ALPHAKEY:        
+                       setSkyBlendingMode(RE_ALPHA_KEY);
+                       break;
+               case R_ALPHAPREMUL:     
+                       setSkyBlendingMode(RE_ALPHA_PREMUL);
+                       break;
+               default:
+                       setSkyBlendingMode(RE_ALPHA_SKY);               
+       }
+       
+       /* SHould use slider when the gamma button is pressed. */
+       if (do_gamma) {         
+               makeGammaTables(2.0);
+       } else {
+               makeGammaTables(1.0);
+       }
+       
+}
 
-       if (R.rectz) MEM_freeN(R.rectz);
-       R.rectz = 0;
+static void mainRenderLoop(void)  /* here the PART and FIELD loops */
+{
+       Part *pa;
+       int blur, fields, fi, totparts, nr;
+
+       /* create mutexes for threaded render */
+       render_abuf_lock = SDL_CreateMutex();
+       load_ibuf_lock = SDL_CreateMutex();
 
+       if(R.rectz) MEM_freeN(R.rectz);
+       R.rectz = NULL;
+       if(R.rectftot) MEM_freeN(R.rectftot);
+       R.rectftot = NULL;
+       
        /* FIELD LOOP */
+       totparts= R.r.xparts*R.r.yparts;
        fields= 1;
-       parts= R.r.xparts*R.r.yparts;
 
        if(R.r.mode & R_FIELDS) {
                fields= 2;
-               R.rectf1= R.rectf2= 0;  /* field rects */
+               R.rectf1= R.rectf2= NULL;       /* field rects */
                R.r.ysch/= 2;
                R.afmy/= 2;
                R.r.yasp*= 2;
                R.ycor= ( (float)R.r.yasp)/( (float)R.r.xasp);
 
        }
-
        
        for(fi=0; fi<fields; fi++) {
 
@@ -874,7 +929,7 @@ void oldRenderLoop(void)  /* here the PART and FIELD loops */
                        if(R.r.mode & R_MBLUR) set_mblur_offs(R.osa-blur);
 
                        initparts(); /* always do, because of border */
-                       setpart(0);
+                       setpart(R.parts.first);
 
                        RE_local_init_render_display();
                        RE_local_clear_render_display(R.win);
@@ -882,20 +937,18 @@ void oldRenderLoop(void)  /* here the PART and FIELD loops */
 
                        prepareScene();
 
-                       /* PARTS */
-                       R.parts.first= R.parts.last= 0;
-                       for(pa=0; pa<parts; pa++) {
+                       /* PARTS LOOP */
+                       nr= 0;
+                       for(pa= R.parts.first; pa; pa= pa->next, nr++) {
 
                                if(RE_local_test_break()) break;
 
-                               if(pa) {        /* because case pa==0 has been done */
-                                       if(setpart(pa)==0) break;
-                               }
+                               setpart(pa);