Giant commit!
authorTon Roosendaal <ton@blender.org>
Mon, 23 Jan 2006 22:05:47 +0000 (22:05 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 23 Jan 2006 22:05:47 +0000 (22:05 +0000)
A full detailed description of this will be done later... is several days
of work. Here's a summary:

Render:
- Full cleanup of render code, removing *all* globals and bad level calls
  all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
  default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
  tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.

Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
  easier use of movies in Blender

PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
  code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)

3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
  (pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
  rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!

Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
  with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
  done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
  window. (yes, output nodes to render-result, and to files, is on the list!)

The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
  system should be built from scratch. I can't really understand this code...
  I expect it is not much needed, especially with advanced layer/passes
  control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
  recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
  effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
  to check first the option to render to a Image window, so Blender can become
  a true single-window application. :)
  For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again

OK... thats what I can quickly recall. Now go compiling!

173 files changed:
source/Makefile
source/blender/Makefile
source/blender/SConscript
source/blender/blenkernel/BKE_bad_level_calls.h
source/blender/blenkernel/BKE_colortools.h
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/BKE_material.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_texture.h
source/blender/blenkernel/BKE_world.h
source/blender/blenkernel/BKE_writeavi.h
source/blender/blenkernel/SConscript
source/blender/blenkernel/bad_level_call_stubs/stubs.c
source/blender/blenkernel/intern/Makefile
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/node_composit.c [new file with mode: 0644]
source/blender/blenkernel/intern/node_shaders.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/blenkernel/intern/writeavi.c
source/blender/blenlib/BLI_blenlib.h
source/blender/blenlib/BLI_jitter.h [moved from source/blender/render/intern/include/outerRenderLoop.h with 64% similarity]
source/blender/blenlib/intern/jitter.c [moved from source/blender/render/intern/source/jitter.c with 80% similarity]
source/blender/blenlib/intern/rct.c
source/blender/blenlib/intern/util.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/imbuf/intern/radiance_hdr.c
source/blender/imbuf/intern/scaling.c
source/blender/imbuf/intern/writeimage.c
source/blender/include/BIF_glutil.h
source/blender/include/BIF_interface.h
source/blender/include/BIF_previewrender.h
source/blender/include/BIF_renderwin.h
source/blender/include/BIF_screen.h
source/blender/include/BIF_space.h
source/blender/include/BIF_toets.h
source/blender/include/BIF_writeimage.h
source/blender/include/BSE_drawview.h
source/blender/include/BSE_node.h
source/blender/include/BSE_sequence.h
source/blender/include/BSE_view.h
source/blender/include/blendef.h
source/blender/include/butspace.h
source/blender/include/interface.h
source/blender/makesdna/DNA_image_types.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/python/api2_2x/Texture.c
source/blender/python/api2_2x/sceneRender.c
source/blender/quicktime/apple/quicktime_export.c
source/blender/quicktime/quicktime_export.h
source/blender/radiosity/SConscript
source/blender/radiosity/extern/include/radio.h
source/blender/radiosity/extern/include/radio_types.h
source/blender/radiosity/intern/source/Makefile
source/blender/radiosity/intern/source/radfactors.c
source/blender/radiosity/intern/source/radio.c
source/blender/radiosity/intern/source/radrender.c
source/blender/render/extern/include/RE_pipeline.h [new file with mode: 0644]
source/blender/render/extern/include/RE_render_ext.h [moved from source/blender/render/intern/include/jitter.h with 50% similarity]
source/blender/render/extern/include/RE_shader_ext.h [new file with mode: 0644]
source/blender/render/extern/include/render.h [deleted file]
source/blender/render/intern/include/RE_callbacks.h [deleted file]
source/blender/render/intern/include/envmap.h
source/blender/render/intern/include/errorHandler.h [deleted file]
source/blender/render/intern/include/gammaCorrectionTables.h
source/blender/render/intern/include/initrender.h
source/blender/render/intern/include/pixelblending.h
source/blender/render/intern/include/pixelshading.h
source/blender/render/intern/include/renderHelp.h [deleted file]
source/blender/render/intern/include/render_types.h [moved from source/blender/render/extern/include/render_types.h with 60% similarity]
source/blender/render/intern/include/rendercore.h
source/blender/render/intern/include/renderdatabase.h [new file with mode: 0644]
source/blender/render/intern/include/renderpipeline.h [moved from source/blender/render/intern/include/renderPreAndPost.h with 57% similarity]
source/blender/render/intern/include/shadbuf.h
source/blender/render/intern/include/texture.h
source/blender/render/intern/include/vanillaRenderPipe.h [deleted file]
source/blender/render/intern/include/vanillaRenderPipe_types.h [deleted file]
source/blender/render/intern/include/zblur.h [deleted file]
source/blender/render/intern/include/zbuf.h
source/blender/render/intern/include/zbuf_types.h [deleted file]
source/blender/render/intern/include/zbufferdatastruct.h [deleted file]
source/blender/render/intern/include/zbufferdatastruct_types.h [deleted file]
source/blender/render/intern/source/RE_callbacks.c [deleted file]
source/blender/render/intern/source/convertblender.c [new file with mode: 0644]
source/blender/render/intern/source/edgeRender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/errorHandler.c [deleted file]
source/blender/render/intern/source/gammaCorrectionTables.c
source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/pipeline.c [new file with mode: 0644]
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 [deleted file]
source/blender/render/intern/source/renderPreAndPost.c [deleted file]
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 [deleted file]
source/blender/render/intern/source/zblur.c [deleted file]
source/blender/render/intern/source/zbuf.c
source/blender/render/intern/source/zbufferdatastruct.c [deleted file]
source/blender/src/Makefile
source/blender/src/SConscript
source/blender/src/butspace.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_scene.c
source/blender/src/buttons_shading.c
source/blender/src/drawimage.c
source/blender/src/drawnode.c
source/blender/src/drawseq.c
source/blender/src/drawview.c
source/blender/src/editmesh_mods.c
source/blender/src/editnode.c
source/blender/src/editobject.c
source/blender/src/editscreen.c
source/blender/src/fluidsim.c
source/blender/src/glutil.c
source/blender/src/header_buttonswin.c
source/blender/src/header_image.c
source/blender/src/header_info.c
source/blender/src/header_node.c
source/blender/src/headerbuttons.c
source/blender/src/interface.c
source/blender/src/interface_icons.c
source/blender/src/interface_panel.c
source/blender/src/preview.blend.c [new file with mode: 0644]
source/blender/src/previewrender.c
source/blender/src/renderwin.c
source/blender/src/screendump.c
source/blender/src/seqaudio.c
source/blender/src/sequence.c
source/blender/src/space.c
source/blender/src/toets.c
source/blender/src/toolbox.c
source/blender/src/transform_conversions.c
source/blender/src/transform_manipulator.c
source/blender/src/usiblender.c
source/blender/src/view.c
source/blender/src/writeavicodec.c
source/blender/src/writeimage.c
source/blender/src/writemovie.c
source/blender/yafray/intern/export_File.cpp
source/blender/yafray/intern/export_Plugin.cpp
source/blender/yafray/intern/yafray_Render.h
source/creator/SConscript
source/creator/creator.c
source/nan_compile.mk

index 87849f29f89cd42f21a1a74e314b44d519f4cbb5..22ca6b68652440cb7d12e19c22db3e789dd70b9f 100644 (file)
@@ -84,7 +84,6 @@ PYPLAYERLIB ?= $(PYLIB)
     GRPLIB += $(NAN_GHOST)/lib/$(DEBUG_DIR)libghost.a
     GRPLIB += $(NAN_STRING)/lib/$(DEBUG_DIR)libstring.a
     GRPLIB += $(OCGDIR)/blender/img/$(DEBUG_DIR)libimg.a
-    GRPLIB += $(OCGDIR)/blender/renderconverter/$(DEBUG_DIR)librenderconverter.a
     GRPLIB += $(OCGDIR)/blender/render/$(DEBUG_DIR)librender.a
     GRPLIB += $(OCGDIR)/blender/radiosity/$(DEBUG_DIR)libradiosity.a
     GRPLIB += $(NAN_OPENNL)/lib/$(DEBUG_DIR)libopennl.a
index e4862f0d845b3fc1543b37b5faf82c43d0388041..ebae59ef0de09c1b804dc3cf239d0dc8caf813c2 100644 (file)
@@ -35,7 +35,7 @@ include nan_definitions.mk
 
 DIRS = blenloader readblenfile
 DIRS += avi imbuf img render radiosity blenlib blenkernel blenpluginapi
-DIRS += makesdna src renderconverter yafray
+DIRS += makesdna src yafray
 DIRS += python
 
 ifeq ($(INTERNATIONAL), true)
index 1c21399b838b4a5c5ef7a52ec9dc7c4a7c3ead35..926dc75e7eaeff5b3c9459f32f88592a493d0ecf 100644 (file)
@@ -13,7 +13,6 @@ SConscript(['avi/SConscript',
             'radiosity/SConscript',
             'readblenfile/SConscript',
             'render/SConscript',
-            'renderconverter/SConscript',
             'src/SConscript',
             'yafray/SConscript'])
 
index 8a86e88406f4fbddf66b799d755470fc0b89df62..1bc02a02ea6eecc0991eb04fb53250fadcff0b9b 100644 (file)
@@ -75,26 +75,6 @@ void error(char *str, ...);
 /* anim.c */
 extern struct ListBase editNurb;
 
-/* displist.c */
-#include "DNA_world_types.h"   /* for render_types */
-#include "render_types.h"
-extern struct RE_Render R;
-float Blinn_Spec(float *n, float *l, float *v, float a, float b, int);
-float Phong_Spec(float *, float *, float *, int, int);
-float CookTorr_Spec(float *n, float *l, float *v, int hard, int);
-float Toon_Spec(float *n, float *l, float *v, float a, float b, int);
-float WardIso_Spec(float *n, float *l, float *v, float a, int);
-
-float Toon_Diff(float *n, float *l, float *v, float a, float b);
-float OrenNayar_Diff(float *n, float *l, float *v, float rough);
-float Minnaert_Diff(float nl, float *n, float *v, float a);
-float Fresnel_Diff(float *vn, float *lv, float *view, float ior, float fac);
-
-void add_to_diffuse(float *, ShadeInput *, float, float, float, float);
-void ramp_diffuse_result(float *diff, ShadeInput *shi);
-void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec);
-void ramp_spec_result(float *, float *, float *, ShadeInput *);
-
 void mainqenter (unsigned short event, short val);
 void waitcursor(int);
 void allqueue(unsigned short event, short val);
@@ -103,9 +83,6 @@ void allqueue(unsigned short event, short val);
 struct Material;
 extern struct Material defmaterial;
 
-/* effect.c */
-void    RE_jitterate1(float *jit1, float *jit2, int num, float rad1);
-void    RE_jitterate2(float *jit1, float *jit2, int num, float rad2);
 
 /* exotic.c */
 void load_editMesh(void);
@@ -119,7 +96,6 @@ int saveover(char *str);
 /* image.c */
 #include "DNA_image_types.h"
 void free_realtime_image(Image *ima); // has to become a callback, opengl stuff
-void RE_make_existing_file(char *name); // from render, but these funcs should be moved anyway 
 
 /* ipo.c */
 void copy_view3d_lock(short val);      // was a hack, to make scene layer ipo's possible
@@ -129,11 +105,12 @@ void allspace(unsigned short event, short val) ;
 #define OOPS_TEST             2
 
 /* mball.c */
-extern ListBase editelems;
+extern struct ListBase editelems;
 
 /* object.c */
-void BPY_free_scriptlink(ScriptLink *slink);
-void BPY_copy_scriptlink(ScriptLink *scriptlink);
+struct ScriptLink;
+void BPY_free_scriptlink(struct ScriptLink *slink);
+void BPY_copy_scriptlink(struct ScriptLink *scriptlink);
 float *give_cursor(void);  // become a callback or argument
 void exit_posemode(int freedata);
 
@@ -149,21 +126,7 @@ void free_editing(struct Editing *ed);     // scenes and sequences problem...
 void BPY_do_all_scripts (short int event);
 int BPY_call_importloader(char *name);
 
-/* texture.c */
-#define FLO 128
-#define INT    96
-struct EnvMap;
-struct Tex;
-
-void do_material_tex(ShadeInput *shi);
-void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, 
-       float *tg, float *tb, float *ta);
-void init_render_textures(void);
-
-void RE_free_envmap(struct EnvMap *env);      
-void RE_free_envmapdata(struct EnvMap *env);
-struct EnvMap *RE_copy_envmap(struct EnvMap *env);
-int RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt);
+
 extern char texstr[20][12];    /* buttons.c */
 
 
index 3dc42dcc8238479866e29a15d222701e8dcf04c8..dd739628fc5ec4b3b4b71c61024ad67744a5426e 100644 (file)
@@ -52,7 +52,9 @@ float                         curvemap_evaluateF(struct CurveMap *cuma, float value);
 float                          curvemapping_evaluateF(struct CurveMapping *cumap, int cur, float value);
 void                           curvemapping_evaluate3F(struct CurveMapping *cumap, float *vecout, const float *vecin);
 void                           curvemapping_evaluateRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
+void                           curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
 void                           curvemapping_do_image(struct CurveMapping *cumap, struct Image *ima);
+void                           curvemapping_premultiply(struct CurveMapping *cumap, int restore);
 
 #endif
 
index 490c8dfc01eb238a28899f95ffda5e4a444a2236..f078fd14753e78691ae69ed8358e6e54dfc62bac 100644 (file)
@@ -96,7 +96,7 @@ typedef struct Global {
        short afbreek, moving;
        short qual, background;
        short winpos, displaymode;      /* used to be in Render */
-       
+       short rendering;                        /* to indicate render is busy, prevent renderwindow events etc */
        /**
         * The current version of Blender.
         */
index 1ae5552104c39877a1d6e786200b297f621ac7c5..250b6dc762fba378065db6d2362890895865cb29 100644 (file)
@@ -49,8 +49,10 @@ struct Image *add_image(char *name);
 void free_unused_animimages(void);
 struct Image *new_image(int width, int height, char *name, short uvtestgrid);
 
-void makepicstring(char *string, int frame);
-void addImageExtension(char *string);
+int BKE_write_ibuf(struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality);
+void BKE_makepicstring(char *string, int frame);
+void BKE_add_image_extension(char *string, int imtype);
+int BKE_imtype_is_movie(int imtype);
 
 struct anim *openanim(char * name, int flags);
 void ima_ibuf_is_nul(struct Tex *tex, struct Image *ima);
index 423a6a0cbf9b38db075fcce8259b8d74055dc8ab..a9609f88c98a046e720036909e05210488aa16b5 100644 (file)
@@ -42,6 +42,7 @@ struct Material;
 struct ID;
 struct Object;
 
+void init_def_material(void);
 void free_material(struct Material *sc); 
 void test_object_materials(struct ID *id);
 void init_material(struct Material *ma);
@@ -56,14 +57,17 @@ ID *material_from(struct Object *ob, int act);
 void assign_material(struct Object *ob, struct Material *ma, int act);
 void new_material_to_objectdata(struct Object *ob);
 
-void init_render_material(struct Material *);
-void init_render_materials(void);
+void init_render_material(struct Material *, int, float *);
+void init_render_materials(int, float *);
 void end_render_material(struct Material *);
 void end_render_materials(void);
 
 void automatname(struct Material *);
 void delete_material_index(void);            
 
+void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col);
+
+
 #ifdef __cplusplus
 }
 #endif
index 7c887e2db6349e3f2644c7a6c51ea400ae772e92..88012978cd269c5bf095b27bd4eeb304d0bc36af 100644 (file)
@@ -103,7 +103,6 @@ void                        ntreeExecTree(struct bNodeTree *ntree, void *callerdata, int thread);
 void                   ntreeEndExecTree(struct bNodeTree *ntree);
 
 void                   ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
-void                   ntreeClearPixelTree(struct bNodeTree *, int, int);
 
 /* ************** GENERIC API, NODES *************** */
 
@@ -171,15 +170,53 @@ struct ShadeResult;
 extern bNodeType *node_all_shaders[];
 
 /* API */
-struct bNode   *nodeShaderAdd(struct bNodeTree *ntree, int type);
-void                   nodeShaderSetExecfunc(struct bNode *node);
 
 void                   ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
-int                            ntreeShaderGetTexco(struct bNodeTree *ntree);
+int                            ntreeShaderGetTexco(struct bNodeTree *ntree, int osa);
 void                   nodeShaderSynchronizeID(struct bNode *node, int copyto);
 
                                /* switch material render loop */
 void                   set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
 
+/* ************** COMPOSIT NODES *************** */
+
+/* note: types are needed to restore callbacks, don't change values */
+#define CMP_NODE_OUTPUT                201
+
+#define CMP_NODE_RGB           202
+#define CMP_NODE_VALUE         203
+#define CMP_NODE_MIX_RGB       204
+#define CMP_NODE_VALTORGB      205
+#define CMP_NODE_RGBTOBW       206
+#define CMP_NODE_NORMAL                207
+#define CMP_NODE_CURVE_VEC     208
+#define CMP_NODE_CURVE_RGB     209
+#define CMP_NODE_ALPHAOVER     210
+#define CMP_NODE_BLUR          211
+#define CMP_NODE_FILTER                212
+
+#define CMP_NODE_IMAGE         220
+#define CMP_NODE_R_RESULT      221
+
+
+/* filter types */
+#define CMP_FILT_SOFT          0
+#define CMP_FILT_SHARP         1
+#define CMP_FILT_LAPLACE       2
+#define CMP_FILT_SOBEL         3
+#define CMP_FILT_PREWITT       4
+#define CMP_FILT_KIRSCH                5
+#define CMP_FILT_SHADOW                6
+
+
+/* the type definitions array */
+extern bNodeType *node_all_composit[];
+
+/* API */
+struct CompBuf;
+void ntreeCompositExecTree(struct bNodeTree *ntree);
+void free_compbuf(struct CompBuf *cbuf); /* internal...*/
+
+
 #endif
 
index 2e4e4917de2647bb51703cf437d3a33d163a6cdf..d0f70907e5ca5e028804ea212897f99990e14ff3 100644 (file)
@@ -73,7 +73,7 @@ void base_init_from_view3d(struct Base *base, struct View3D *v3d);
 struct Object *copy_object(struct Object *ob);
 void expand_local_object(struct Object *ob);
 void make_local_object(struct Object *ob);
-void set_mblur_offs(int blur);
+void set_mblur_offs(float blur);
 void disable_speed_curve(int val);
 float bsystem_time(struct Object *ob, struct Object *par, float cfra, float ofs);
 void object_to_mat3(struct Object *ob, float mat[][3]);
index a7eea6f6393eb8ba04e522861c9ff468bc06a536..4aa4c09dccc6865a9c4273069d5fb62f40278053 100644 (file)
@@ -53,6 +53,7 @@ struct QuicktimeCodecData;
 }
 
 
+#define SETLOOPER(s, b) sce= s, b= s->base.first; b; b= (b->next?b->next:s->set?(s=s->set)->base.first:NULL)
 
 
 void free_avicodecdata(struct AviCodecData *acd);
index 033de758c7b9d2ba458de2f81954a4cda5f70fe4..a34ef43cab75f7f265657d907a36642b17ab3ee5 100644 (file)
@@ -41,6 +41,7 @@ struct LampRen;
 struct ColorBand;
 struct HaloRen;
 struct TexMapping;
+struct EnvMap;
 
 /*  in ColorBand struct */
 #define MAXCOLORBAND 16
@@ -65,5 +66,12 @@ struct Tex *give_current_texture(struct Object *ob, int act);
 struct TexMapping *add_mapping(void);
 void init_mapping(struct TexMapping *texmap);
 
+
+void    BKE_free_envmapdata(struct EnvMap *env);
+void    BKE_free_envmap(struct EnvMap *env);
+struct EnvMap *BKE_add_envmap(void);
+struct EnvMap *BKE_copy_envmap(struct EnvMap *env);
+
+
 #endif
 
index cedff61f2dd1b42611aabd90105d3378091a73b3..b51eaff420cb968133a43d946c334ef1203ae692 100644 (file)
@@ -40,7 +40,6 @@ void free_world(struct World *sc);
 struct World *add_world(char *name);
 struct World *copy_world(struct World *wrld);
 void make_local_world(struct World *wrld);
-void init_render_world(void);
 
 #endif
 
index f63342ea0476a6e5477de043f518729ee1109d8c..af442600c6b5255ee9849d40e997fdc17f98f3bd 100644 (file)
 extern "C" {
 #endif
 
-void start_avi(void);
+/* generic blender movie support, could move to own module */
+
+typedef struct bMovieHandle {
+       void (*start_movie)(RenderData *rd, int rectx, int recty);
+       void (*append_movie)(int frame, int *pixels, int rectx, int recty);
+       void (*end_movie)(void);
+} bMovieHandle;
+
+bMovieHandle *BKE_get_movie_handle(int imtype);
+
+
+/* ************** */   
+
+struct RenderData;     
+void start_avi(struct RenderData *rd, int rectx, int recty);
 void end_avi(void);
-void append_avi(int frame);
-void makeavistring(char *string);
+void append_avi(int frame, int *pixels, int rectx, int recty);
+void makeavistring (struct RenderData *rd, char *string);
+
+
 
 #ifdef __cplusplus
 }
index acbb15a4ecd25194b2f3f469b582ded1ededab7a..8a5fd47388f36454a162e254e0fa5560c8cf9a5b 100644 (file)
@@ -46,6 +46,7 @@ source_files = ['intern/constraint.c',
                 'intern/softbody.c',
                'intern/node.c',
                'intern/node_shaders.c',
+               'intern/node_composit.c',
                'intern/colortools.c',
                 'intern/texture.c']
 
@@ -60,6 +61,7 @@ blenkernel_env.Append (CPPPATH = ['.',
                                   '../../../intern/decimation/extern',
                                   '../imbuf',
                                   '../avi',
+                                 '../quicktime',
                                   '#/intern/elbeem/extern',
                                   '#/intern/iksolver/extern',
                                   '../blenloader'])
index 44997480779d7a1b5117d4b09a0f427742599047..f8c44730bdf7824f7c41d3bc38bda027aeb5e500 100644 (file)
@@ -102,37 +102,11 @@ void error(char *str, ...){}
 /* anim.c */
 ListBase editNurb;
 
-/* displist.c */
-#include "DNA_world_types.h"   /* for render_types */
-#include "render_types.h"
-struct RE_Render R;
-
-float Phong_Spec(float *n, float *l, float *v, int hard, int tangent){return 0;}
-float Blinn_Spec(float *n, float *l, float *v, float a, float b, int tangent){return 0;}
-float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent){return 0;}
-float Toon_Spec(float *n, float *l, float *v, float a, float b, int tangent){return 0;}
-float WardIso_Spec(float *n, float *l, float *v, float a, int tangent){return 0;}
-
-float Toon_Diff(float *n, float *l, float *v, float a, float b){return 0;}
-float OrenNayar_Diff(float *n, float *l, float *v, float rough){return 0;}
-float Minnaert_Diff(float nl, float *n, float *v, float a){return 0;}
-float Fresnel_Diff(float *vn, float *lv, float *view, float ior, float fac){return 0;}
-
-void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, float g, float b){}
-void ramp_diffuse_result(float *diff, ShadeInput *shi){}
-void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec){}
-void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi){}
-
-
 void waitcursor(int val){}
 void allqueue(unsigned short event, short val){}
 #define REDRAWVIEW3D   0x4010
 Material defmaterial;
 
-/* effect.c */
-void    RE_jitterate1(float *jit1, float *jit2, int num, float rad1){}
-void    RE_jitterate2(float *jit1, float *jit2, int num, float rad2){}
-
 /* exotic.c */
 void load_editMesh(void){}
 void make_editMesh(void){}
@@ -143,7 +117,6 @@ int saveover(char *str){ return 0;}
 /* image.c */
 #include "DNA_image_types.h"
 void free_realtime_image(Image *ima){} // has to become a callback, opengl stuff
-void RE_make_existing_file(char *name){} // from render, but these funcs should be moved anyway 
 
 /* ipo.c */
 void copy_view3d_lock(short val){}     // was a hack, to make scene layer ipo's possible
@@ -202,20 +175,7 @@ int BPY_call_importloader(char *name)
 /* texture.c */
 #define FLO 128
 #define INT    96
-       /* struct EnvMap; */
-       /* struct Tex; */
-
-void do_material_tex(ShadeInput *shi){}
-void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta){}
 
-void    RE_free_envmap(struct EnvMap *env){}      
-struct EnvMap *RE_copy_envmap(struct EnvMap *env){ return env;}
-void    RE_free_envmapdata(struct EnvMap *env){}
-void init_render_textures(void){}
-
-int     RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt){
-   return 0;
-}
 
 char texstr[20][12];   /* buttons.c */
 
index 1bdeda1841f5217096ef97ca8e9c0ce80dc2daac..c173051e862f2f4ea7e3d2b300123fa109876ec8 100644 (file)
@@ -87,3 +87,7 @@ ifeq ($(WITH_OPENEXR), true)
     CPPFLAGS += -DWITH_OPENEXR
 endif
 
+ifeq ($(WITH_QUICKTIME), true)
+       CPPFLAGS += -I../../quicktime
+       CPPFLAGS += -DWITH_QUICKTIME
+endif
index b160dd415223306b3ed7068812cd4b53d3e93542..642ce855383137bec10c50e4b0e7b2ae6cb38e9b 100644 (file)
@@ -66,7 +66,6 @@
 #include "BLI_blenlib.h"
 
 #include "nla.h"
-#include "render.h"
 
 /* *********************** NOTE ON POSE AND ACTION **********************
 
@@ -755,9 +754,9 @@ static float nla_time(float cfra, float unit)
        extern float bluroffs;  // bad construct, borrowed from object.c for now
        
        /* 2nd field */
-       if(R.flag & R_SEC_FIELD) {
-               if(R.r.mode & R_FIELDSTILL); else cfra+= 0.5f*unit;
-       }
+//     if(R.flag & R_SEC_FIELD) {
+//             if(R.r.mode & R_FIELDSTILL); else cfra+= 0.5f*unit;
+//     }
        
        /* motion blur */
        cfra+= unit*bluroffs;
index 43b3774045583fa94f08a3eb2613af075526d46c..992139a5120c107062cd53985ae2dbf9dba78ffe 100644 (file)
@@ -1,4 +1,3 @@
-
 /*  blender.c   jan 94     MIXED MODEL
  * 
  * common help functions and data
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #ifndef WIN32 
     #include <unistd.h> // for read close
     #include <sys/param.h> // for MAXPATHLEN
 #include <fcntl.h> // for open
 
 #include "MEM_guardedalloc.h"
+
 #include "DNA_listBase.h"
 #include "DNA_sdna_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_object_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_scene_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
@@ -233,10 +230,6 @@ static void clear_global(void)
        free_main(G.main); /* free all lib data */
        freefastshade();        /* othwerwise old lamp settings stay active */
 
-
-       /* prevent hanging vars */      
-       R.backbuf= 0;
-       
        /* force all queues to be left */
        winqueue_break= 1;
        
@@ -275,7 +268,6 @@ static void clean_paths(Main *main)
        Sequence *seq;
        Strip *strip;
        
-       
        while(image) {
                BLI_clean(image->name);
                image= image->id.next;
index 30c74fd65cb36eaa611cccb679555c96a12ea014..5b4c4ca107f7e8cc02cd4ee2d40af175fc16105c 100644 (file)
@@ -402,7 +402,7 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
 }
 
 /* call when you do images etc, needs restore too. also verifies tables */
-static void curvemapping_premultiply(CurveMapping *cumap, int restore)
+void curvemapping_premultiply(CurveMapping *cumap, int restore)
 {
        static CurveMapPoint *table[3]= {NULL, NULL, NULL};
        int a;
@@ -545,7 +545,7 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float *vecout, const float *
 
 
 /* RGB with black/white points and premult. tables are checked */
-static void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const float *vecin)
+void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const float *vecin)
 {
        float fac;
        
index ae187c0e0f7f81543e194a35a7addae6d92d4673..9a4a8f62600d1fe025d6a9714a7d239522a1580a 100644 (file)
@@ -1385,6 +1385,8 @@ void DAG_scene_sort(struct Scene *sce)
                        printf(" %s\n", base->object->id.name);
                }
        }
+       /* temporal...? */
+       G.scene->recalc |= SCE_PRV_CHANGED;     /* test for 3d preview */
 }
 
 /* node was checked to have lasttime != curtime and is if type ID_OB */
index 668e8d6e71c299b04507b9ae885f5c4c4e0ee1ac..2e7f821abd70b366f591afc1bd8cf41133e0598e 100644 (file)
@@ -1,4 +1,3 @@
-
 /*  displist.c
  * 
  * 
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
 #include "BKE_modifier.h"
 
 #include "nla.h" /* For __NLA: Please do not remove yet */
-#include "render.h"
 
 
-/***/
-
-typedef struct _FastLamp FastLamp;
-struct _FastLamp {
-       FastLamp *next;
-       
-       short type, mode, lay, rt;
-       float co[3];
-       float vec[3];
-       float dist, distkw, att1, att2, spotsi, spotbl, r, g, b;
-};
-
-/***/
-
 static void boundbox_displist(Object *ob);
 
-static FastLamp *fastlamplist= NULL;
-static float fviewmat[4][4];
-
 void displistmesh_free(DispListMesh *dlm) 
 {
        // also check on mvert and mface, can be NULL after decimator (ton)
@@ -288,358 +265,18 @@ void copy_displist(ListBase *lbn, ListBase *lb)
        }
 }
 
-static void initfastshade(void)
+void initfastshade(void)
 {
-       Base *base;
-       Scene *setscene;
-       Object *ob;
-       Lamp *la;
-       FastLamp *fl;
-       float mat[4][4];
-
-       init_render_world();
-       
-       if(fastlamplist) return;
-       if(G.scene->camera==0) G.scene->camera= scene_find_camera(G.scene);
-       if(G.scene->camera==0) return;
-
-       /* copied from 'roteerscene' (does that function still exist? (ton) */
-       where_is_object(G.scene->camera);
-       Mat4CpyMat4(R.viewinv, G.scene->camera->obmat);
-       Mat4Ortho(R.viewinv);
-       Mat4Invert(fviewmat, R.viewinv);
-
-       /* initrendertexture(); */
-       setscene = G.scene->set;
-       base= G.scene->base.first;
-       while(base) {
-               ob= base->object;
-               if( ob->type==OB_LAMP && (base->lay & G.scene->lay)) {
-                       
-                       Mat4MulMat4(mat, ob->obmat, fviewmat);
-                       
-                       la= ob->data;
-                       fl= MEM_mallocN(sizeof(FastLamp), "initfastshade2");
-
-                       fl->next= fastlamplist;
-                       fastlamplist= fl;
-
-                       fl->type= la->type;
-                       fl->mode= la->mode;
-                       fl->lay= base->lay;
-                       
-                       fl->vec[0]= mat[2][0];
-                       fl->vec[1]= mat[2][1];
-                       fl->vec[2]= mat[2][2];
-                       Normalise(fl->vec);
-                       
-                       fl->co[0]= mat[3][0];
-                       fl->co[1]= mat[3][1];
-                       fl->co[2]= mat[3][2];
-
-                       fl->dist= la->dist;
-                       fl->distkw= fl->dist*fl->dist;
-                       fl->att1= la->att1;
-                       fl->att2= la->att2;
-
-                       fl->spotsi= (float)cos( M_PI*la->spotsize/360.0 );
-                       fl->spotbl= (1.0f-fl->spotsi)*la->spotblend;
-       
-                       fl->r= la->energy*la->r;
-                       fl->g= la->energy*la->g;
-                       fl->b= la->energy*la->b;
-               }
-               
-               if(base->next==0 && setscene && setscene->set) {/*if(base->next==0 && G.scene->set && base==G.scene->base.last) {*/
-                       setscene = setscene->set;
-                       base= setscene->base.first; /* base= G.scene->set->base.first;*/
-               } else {
-                       base= base->next;
-               }
-       }
 }
 
 
 void freefastshade()
 {
-       while (fastlamplist) {
-               FastLamp *fl= fastlamplist;
-               fastlamplist= fl->next;
-               
-               MEM_freeN(fl);
-       }
 }
 
 
 static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2, char *vertcol)
 {
-       ShadeInput shi;
-       FastLamp *fl;
-       float i, t, inp, is, soft,  lv[3], lampdist, ld;
-       float diff1[3], diff2[3];
-       float isr1=0, isg1=0, isb1=0, isr=0, isg=0, isb=0;
-       int a, back;
-
-       if(ma==0) return;
-       
-       shi.mat= ma;
-       shi.vlr= NULL;  // have to do this!
-       
-       // 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) {
-                       shi.r= vertcol[3]/255.0;
-                       shi.g= vertcol[2]/255.0;
-                       shi.b= vertcol[1]/255.0;
-               }
-       }
-       
-       if(ma->texco) {
-               VECCOPY(shi.lo, orco);
-               
-               if(ma->texco & TEXCO_GLOB) {
-                       VECCOPY(shi.gl, shi.lo);
-               }
-               if(ma->texco & TEXCO_WINDOW) {
-                       VECCOPY(shi.winco, shi.lo);
-               }
-               if(ma->texco & TEXCO_STICKY) {
-                       VECCOPY(shi.sticky, shi.lo);
-               }
-               if(ma->texco & TEXCO_UV) {
-                       VECCOPY(shi.uv, shi.lo);
-               }
-               if(ma->texco & TEXCO_OBJECT) {
-                       VECCOPY(shi.co, shi.lo);
-               }
-               if(ma->texco & TEXCO_NORM) {
-                       VECCOPY(shi.orn, shi.vn);
-               }
-               if(ma->texco & TEXCO_REFL) {
-                       
-                       inp= 2.0*(shi.vn[2]);
-                       shi.ref[0]= (inp*shi.vn[0]);
-                       shi.ref[1]= (inp*shi.vn[1]);
-                       shi.ref[2]= (-1.0+inp*shi.vn[2]);
-               }
-
-               do_material_tex(&shi);
-       }
-
-       if(ma->mode & MA_SHLESS) {
-               if(vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) {
-                       float fac;
-                       fac= vertcol[3]*shi.r;
-                       col1[3]= fac>=1.0?255:(char)fac;
-                       fac= vertcol[2]*shi.g;
-                       col1[2]= fac>=1.0?255:(char)fac;
-                       fac= vertcol[1]*shi.b;
-                       col1[1]= fac>=1.0?255:(char)fac;
-               }
-               else {
-                       int fac;
-                       fac= (int) (255.0*shi.r);
-                       col1[3]= fac>255?255:(char)fac;
-                       fac= (int) (255.0*shi.g);
-                       col1[2]= fac>255?255:(char)fac;
-                       fac= (int) (255.0*shi.b);
-                       col1[1]= fac>255?255:(char)fac;
-               }
-               if(col2) {
-                       col2[3]= col1[3];
-                       col2[2]= col1[2];
-                       col2[1]= col1[1];
-               }
-               return;
-       }
-
-       if( vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) {
-               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]= 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;
-       shi.view[1]= 0.0;
-       shi.view[2]= 1.0;
-       
-       Normalise(shi.view);
-
-       for (fl= fastlamplist; fl; fl= fl->next) {
-               /* if(fl->mode & LA_LAYER) if((fl->lay & ma->lay)==0) continue; */
-
-               if(fl->type==LA_SUN || fl->type==LA_HEMI) {
-                       VECCOPY(lv, fl->vec);
-                       lampdist= 1.0;
-               }
-               else {
-                       lv[0]= fl->co[0] - co[0];
-                       lv[1]= fl->co[1] - co[1];
-                       lv[2]= fl->co[2] - co[2];
-                       ld= sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2]);
-                       lv[0]/=ld;
-                       lv[1]/=ld;
-                       lv[2]/=ld;
-
-                       if(fl->mode & LA_QUAD) {
-                               t= 1.0;
-                               if(fl->att1>0.0)
-                                       t= fl->dist/(fl->dist+fl->att1*ld);
-                               if(fl->att2>0.0)
-                                       t*= fl->distkw/(fl->distkw+fl->att2*ld*ld);
-
-                               lampdist= t;
-                       }
-                       else {
-                               lampdist= (fl->dist/(fl->dist+ld));
-                       }
-
-                       if(fl->mode & LA_SPHERE) {
-                               t= fl->dist - ld;
-                               if(t<0.0) continue;
-                               
-                               t/= fl->dist;
-                               lampdist*= (t);
-                       }
-               }
-
-               if(fl->type==LA_SPOT) {
-                       inp= lv[0]*fl->vec[0]+lv[1]*fl->vec[1]+lv[2]*fl->vec[2];
-                       if(inp<fl->spotsi) continue;
-                       else {
-                               t= inp-fl->spotsi;
-                               i= 1.0;
-                               soft= 1.0;
-                               if(t<fl->spotbl && fl->spotbl!=0.0) {
-                                       /* soft area */
-                                       i= t/fl->spotbl;
-                                       t= i*i;
-                                       soft= (3.0*t-2.0*t*i);
-                                       inp*= soft;
-                               }
-
-                               lampdist*=inp;
-                       }
-               }
-
-               if(fl->mode & LA_NO_DIFF) is= 0.0;
-               else {
-                       is= nor[0]*lv[0]+ nor[1]*lv[1]+ nor[2]*lv[2];
-       
-                       if(ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(nor, lv, shi.view, ma->roughness);
-                       else if(ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]);
-                       else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(is, nor, shi.view, ma->darkness);
-                       else if(ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]);
-               }
-               
-               back= 0;
-               if(is<0.0) {
-                       back= 1;
-                       is= -is;
-               }
-               inp= is*lampdist*shi.refl;
-
-               if(back==0) {
-                       add_to_diffuse(diff1, &shi, is, inp*fl->r, inp*fl->g, inp*fl->b);
-                       //diff1[0]+= inp*fl->r;
-                       //diff1[1]+= inp*fl->g;
-                       //diff1[2]+= inp*fl->b;
-               } else if(col2) {
-                       add_to_diffuse(diff2, &shi, is, inp*fl->r, inp*fl->g, inp*fl->b);
-                       //diff2[0]+= inp*fl->r;
-                       //diff2[1]+= inp*fl->g;
-                       //diff2[2]+= inp*fl->b;
-               }
-               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, shi.har, 0);
-                       else if(ma->spec_shader==MA_SPEC_COOKTORR) 
-                               specfac= CookTorr_Spec(nor, lv, shi.view, shi.har, 0);
-                       else if(ma->spec_shader==MA_SPEC_BLINN) 
-                               specfac= Blinn_Spec(nor, lv, shi.view, ma->refrac, (float)shi.har, 0);
-                       else if(ma->spec_shader==MA_SPEC_WARDISO)
-                               specfac= WardIso_Spec(nor, lv, shi.view, ma->rms, 0);
-                       else 
-                               specfac= Toon_Spec(nor, lv, shi.view, ma->param[2], ma->param[3], 0);
-                       
-                       if(specfac>0) {
-                               t= specfac*shi.spec*lampdist;
-                               if(back==0) {
-                                       if(ma->mode & MA_RAMP_SPEC) {
-                                               float spec[3];
-                                               do_specular_ramp(&shi, specfac, t, spec);
-                                               isr+= t*(fl->r * spec[0]);
-                                               isg+= t*(fl->g * spec[1]);
-                                               isb+= t*(fl->b * spec[2]);
-                                       }
-                                       else {
-                                               isr+= t*(fl->r * shi.specr);
-                                               isg+= t*(fl->g * shi.specg);
-                                               isb+= t*(fl->b * shi.specb);
-                                       }
-                               }
-                               else if(col2) {
-                                       if(ma->mode & MA_RAMP_SPEC) {
-                                               float spec[3];
-                                               do_specular_ramp(&shi, specfac, t, spec);
-                                               isr1+= t*(fl->r * spec[0]);
-                                               isg1+= t*(fl->g * spec[1]);
-                                               isb1+= t*(fl->b * spec[2]);
-                                       }
-                                       else {
-                                               isr1+= t*(fl->r * shi.specr);
-                                               isg1+= t*(fl->g * shi.specg);
-                                               isb1+= t*(fl->b * shi.specb);
-                                       }
-                               }
-                       }
-               }
-
-       }
-
-       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] + shi.ambr +isr);
-       if(a>255) col1[3]= 255; 
-       else col1[3]= a;
-       a= 256*(diff1[1] + shi.ambg +isg);
-       if(a>255) col1[2]= 255; 
-       else col1[2]= a;
-       a= 256*(diff1[2] + shi.ambb +isb);
-       if(a>255) col1[1]= 255; 
-       else col1[1]= a;
-
-       if(col2) {
-               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] + shi.ambr +isr1);
-               if(a>255) col2[3]= 255; 
-               else col2[3]= a;
-               a= 256*(diff2[1] + shi.ambg +isg1);
-               if(a>255) col2[2]= 255; 
-               else col2[2]= a;
-               a= 256*(diff2[2] + shi.ambb +isb1);
-               if(a>255) col2[1]= 255; 
-               else col2[1]= a;
-       }
-
 }
 
 void addnormalsDispList(Object *ob, ListBase *lb)
@@ -710,27 +347,6 @@ void addnormalsDispList(Object *ob, ListBase *lb)
 
 static void init_fastshade_for_ob(Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3])
 {
-       float tmat[4][4];
-       int a;
-
-       initfastshade();
-
-       Mat4MulMat4(mat, ob->obmat, fviewmat);
-       
-       Mat4Invert(tmat, mat);
-       Mat3CpyMat4(imat, tmat);
-       if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0);
-
-       if (need_orco_r) *need_orco_r= 0;
-       for(a=0; a<ob->totcol; a++) {
-               Material *ma= give_current_material(ob, a+1);
-               if(ma) {
-                       init_render_material(ma);
-                       if(ma->texco & TEXCO_ORCO) {
-                               if (need_orco_r) *need_orco_r= 1;
-                       }
-               }
-       }
 }
 
 void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
@@ -833,7 +449,7 @@ void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r
                        Mat4MulVecfl(mat, vec);
                        fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2, mcol);
                }
-       }
+       } 
        MEM_freeN(vnors);
        displistmesh_free(dlm);
 
@@ -1693,304 +1309,9 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
        boundbox_displist(ob);
 }
 
-/*******************************/
-/*****       OUTLINE       *****/
-/*******************************/
-
-typedef struct Sample{
-       short x, y;
-} Sample;
-
-typedef struct Segment{
-       /* coordinates */
-       struct Segment * next, * prev;
-       float co[2];
-} Segment;
-
-
-
-static int dflt_in_out(struct ImBuf * ibuf, int x, int y)
-{
-       unsigned char * rect;
-       
-       if (ibuf == 0) return (0);
-       if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y || ibuf->rect == 0) return (-1);
-       
-       rect = (unsigned char *) (ibuf->rect + (y * ibuf->x) + x);
-       if (rect[0] > 0x81) return (1);
-       return(0);
-}
-
-
-static Sample * outline(struct ImBuf * ibuf,
-                                int (*in_or_out)(struct ImBuf *, int, int))
-{
-       static int dirs[8][2] = {
-               {-1,  0}, {-1,  1},     {0,  1}, {1,  1}, 
-               {1,  0}, {1, -1}, {0, -1}, {-1, -1}
-       };
-       
-       int dir, x, y, in, i;
-       int count, sampcount;
-       int startx = 0, starty = 0;
-       Sample * samp, * oldsamp;
-       
-       /* input:
-        * 1 - image 
-        * 2 - pointer to function that defines which pixel 'in' or 'out' is
-        */
-       
-       if (ibuf == 0) return (0);
-       if (ibuf->rect == 0) return (0);
-       
-       if (in_or_out == 0) in_or_out = dflt_in_out;
-       in = in_or_out(ibuf, 0, 0);
-       
-       /* search for first transition, and continue from there */      
-       for (y = 0; y < ibuf->y; y++) {
-               for (x = 0; x < ibuf->x; x++) {
-                       if (in_or_out(ibuf, x, y) != in) {
-                               /* found first 'other' point !! */
-                               
-                               if (x != startx) dir = 0;
-                               else dir = 6;
-                               
-                               startx = x; starty = y;
-                               count = 1;
-                               sampcount = 2000;
-                               samp = MEM_mallocN(sampcount * sizeof(Sample), "wire_samples");
-                               
-                               do{
-                                       samp[count].x = x; samp[count].y = y;
-                                       count++;
-                                       
-                                       if (count >= sampcount) {
-                                               oldsamp = samp;
-                                               samp = MEM_mallocN(2 * sampcount * sizeof(Sample), "wire_samples");
-                                               memcpy(samp, oldsamp, sampcount * sizeof(Sample));
-                                               sampcount *= 2;
-                                               MEM_freeN(oldsamp);
-                                       }
-                                       
-                                       i = 0;
-                                       while(in_or_out(ibuf, x + dirs[dir][0], y + dirs[dir][1]) == in) {
-                                               dir = (dir + 1) & 0x7;
-                                               if (i++ == 9) break;
-                                       }
-                                       
-                                       if (i >= 8) {
-                                               /* this has to be a loose point */
-                                               break;
-                                       }
-                                       
-                                       x += dirs[dir][0];
-                                       y += dirs[dir][1];
-                                       dir = (dir - 3) & 0x7;
-                               } while(x != startx || y != starty);
-                               
-                               if (i >= 8) {
-                                       /* patch for loose points */
-                                       MEM_freeN(samp);
-                               } else {
-                                       count = count - 1;
-                                       samp[0].x = count >> 16;
-                                       samp[0].y = count;
-                                       return(samp);
-                               }
-                       }
-               }
-       }
-       /* printf("no transition \n"); */
-       return(0);
-}
-
-
-
-/*******************************/
-/*****      WIREFRAME      *****/
-/*******************************/
-
-
-static float DistToLine2D(short *v1, short *v2, short *v3)   /* using Hesse formula :NO LINE PIECE! */
-{
-       float a[2],deler;
-
-       a[0] = v2[1]-v3[1];
-       a[1] = v3[0]-v2[0];
-       deler = sqrt(a[0]*a[0]+a[1]*a[1]);
-       if(deler == 0.0) return 0;
-
-       return fabs((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler;
-
-}
-
-static float ComputeMaxShpError(Sample *samp, int first, int last, int *splitPoint)
-    /* samp:  Array of digitized points        */
-    /* first, last:  Indices defining region   */
-    /* splitpoint:  Point of maximum error     */
-{
-    int                i;
-    float      maxDist;                                /*  Maximum error               */
-    float      dist;                                   /*  Current error               */
-    *splitPoint = (last - first + 1) / 2;
-    maxDist = 0.0;
-       
-    for (i = first + 1; i < last; i++) {                               
-               dist = DistToLine2D((short *)(samp+i), (short *)(samp+first), (short *)(samp+last));
-
-               if (dist >= maxDist) {
-               maxDist = dist;
-               *splitPoint = i;
-               }
-    }
-
-    return (maxDist);
-}
-
-
-static void FitPoly(Sample *samp, int first, int last, float shperr, ListBase *seglist)
-    /* Samp: Array of digitized points */
-    /* first,last: Indices of first and last pts in region */
-    /* spherr: User-defined error squared         */
-{
-    Segment    * seg;                          /* Control points segment*/
-    float      maxError;                       /*  Maximum fitting error        */
-    int                splitPoint;                     /*  Point to split point set at  */
-    int                nPts;                           /*  Number of points in subset  */
-       
-    nPts = last - first + 1;
-
-    /*  Use heuristic if region only has two points in it */
-
-       seg = MEM_mallocN(sizeof(Segment), "wure_segment");
-
-       seg->co[0] = samp[first].x;
-       seg->co[1] = samp[first].y;
-       
-    if (nPts == 2) {
-               BLI_addtail(seglist, seg);
-               return;
-    }
-
-       maxError = ComputeMaxShpError(samp, first, last, &splitPoint);
-       if (maxError < shperr) {
-               BLI_addtail(seglist, seg);
-               return;
-       }
-       
-    /* Fitting failed -- split at max error point and fit recursively */
-       
-    FitPoly(samp, first, splitPoint, shperr, seglist);
-    FitPoly(samp, splitPoint, last, shperr, seglist);
-       
-       MEM_freeN(seg);
-}
-
-
-static void ibuf2wire(ListBase * wireframe, struct ImBuf * ibuf)
-{
-       int count;
-       Sample * samp;
-       
-       /* first make a list of samples */
-       
-       samp = outline(ibuf, 0);
-       if (samp == 0) return;
-       
-       count = (samp[0].x << 16) + samp[0].y;
-       if (count) FitPoly(samp, 1, count, 1.0, wireframe); /* was 3.0. Frank */
-
-       MEM_freeN(samp);
-}
-
-
-
 void imagestodisplist(void)
 {
-       Base *base;
-       Object *ob;
-       Material *ma;
-       Tex *tex;
-       Mesh *me;
-       ListBase _wireframe, *wireframe;
-       DispList *dl;
-       Segment *seg;
-       float *data, xfac, yfac, xsi, ysi, vec[3], dum;
-       int tot;
-       
-       _wireframe.first= 0;
-       _wireframe.last= 0;
-       wireframe = &_wireframe;
-       
-       init_render_textures();
-       
-       base= G.scene->base.first;
-       while(base) {
-               if(( (base->flag & SELECT) && (base->lay & G.scene->lay) ) ) {
-                       if( base->object->type==OB_MESH) {
-                               ob= base->object;
-                               me= ob->data;
-                               
-                               ma= give_current_material(ob, 1);
-       
-                               if(ma && ma->mtex[0] && ma->mtex[0]->tex) {
-                                       tex= ma->mtex[0]->tex;
-                                       
-                                       /* this takes care of correct loading of new imbufs */
-                                       externtex(ma->mtex[0], vec, &dum, &dum, &dum, &dum, &dum);
-                                       
-                                       if(tex->type==TEX_IMAGE && tex->ima && tex->ima->ibuf) {                                
-                                               
-                                               ob->dtx |= OB_DRAWIMAGE;
-                                               
-                                               ibuf2wire(wireframe, tex->ima->ibuf);
-
-                                               tot= 0;
-                                               seg = wireframe->first;
-                                               while (seg) {
-                                                       tot++;
-                                                       seg = seg->next;
-                                               }
-       
-                                               if(tot) {
-                                                       float size[3];
-
-                                                       freedisplist(&(ob->disp));
-
-                                                       dl= MEM_callocN(sizeof(DispList), "makeDispListimage");
-                                                       dl->verts= MEM_callocN(3*sizeof(float)*tot, "dlverts");
-                                                       
-                                                       BLI_addtail(&(ob->disp), dl);
-                                                       dl->type= DL_POLY;
-                                                       dl->parts= 1;
-                                                       dl->nr= tot;
-                                                       
-                                                       xsi= 0.5*(tex->ima->ibuf->x);
-                                                       ysi= 0.5*(tex->ima->ibuf->y);
-
-                                                       mesh_get_texspace(me, NULL, NULL, size);
-                                                       xfac= size[0]/xsi;
-                                                       yfac= size[1]/ysi;
-                                                                                               
-                                                       data= dl->verts;
-                                                       seg = wireframe->first;
-                                                       while (seg) {
-                                                               data[0]= xfac*(seg->co[0]-xsi);
-                                                               data[1]= yfac*(seg->co[1]-ysi);
-                                                               data+= 3;
-                                                               seg = seg->next;
-                                                       }
-                                                       BLI_freelistN(wireframe);
-                                               }
-                                       }
-                               }
-                       }
-               }
-               base= base->next;
-       }
-       
-       allqueue(REDRAWVIEW3D, 0);
+       /* removed */
 }
 
 static void boundbox_displist(Object *ob)
index fc27de989dc890f43dc3d51c5d2f9482d96c9068..663fe02aaf03854c07365e5364f22a52c97e9592 100644 (file)
@@ -52,8 +52,9 @@
 #include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
 
-#include "BLI_blenlib.h"
 #include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+#include "BLI_jitter.h"
 #include "BLI_rand.h"
 
 #include "BKE_action.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
-#include "render.h"            // externtex, bad level call (ton)
 #include "PIL_time.h"
 
+#include "RE_render_ext.h"
+
 /* temporal struct, used for reading return of mesh_get_mapped_verts_nors() */
 typedef struct VeNoCo {
        float co[3], no[3];
@@ -1217,9 +1219,9 @@ static void init_mv_jit(float *jit, int num, int seed2)
        jit2= MEM_mallocN(12 + 2*sizeof(float)*num, "initjit");
 
        for (i=0 ; i<4 ; i++) {
-               RE_jitterate1(jit, jit2, num, rad1);
-               RE_jitterate1(jit, jit2, num, rad1);
-               RE_jitterate2(jit, jit2, num, rad2);
+               BLI_jitterate1(jit, jit2, num, rad1);
+               BLI_jitterate1(jit, jit2, num, rad1);
+               BLI_jitterate2(jit, jit2, num, rad2);
        }
        MEM_freeN(jit2);
        rng_free(rng);
@@ -1609,8 +1611,7 @@ void build_particle_system(Object *ob)
        if(me->totvert==0) return;
        
        if(ob==G.obedit) return;
-       
-       totpart= (R.flag & R_RENDERING)?paf->totpart:(paf->disp*paf->totpart)/100;
+       totpart= (G.rendering)?paf->totpart:(paf->disp*paf->totpart)/100;
        if(totpart==0) return;
        
        /* No returns after this line! */
index 267114952525f199ede86b5a1a8c11cd44345687..b37e787729ea4ea5a8734851c1bb1e586a66f6d3 100644 (file)
@@ -51,6 +51,7 @@
 #include "DNA_image_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_packedFile_types.h"
+#include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 
 #include "BLI_blenlib.h"
@@ -275,86 +276,155 @@ void free_unused_animimages()
 
 /* *********** READ AND WRITE ************** */
 
-void makepicstring(char *string, int frame)
+int BKE_imtype_is_movie(int imtype)
 {
-       short i,len;
-       char num[10], *extension;
-
-       if (string==0) return;
-
-       extension= "";
-
-       strcpy(string, G.scene->r.pic);
-       BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
-
-       len= strlen(string);
-                       
-       /* can also: sprintf(num, "%04d", frame); */
-
-       i=4-sprintf(num,"%d",frame);
-       for(;i>0;i--){
-               string[len]='0';
-               len++;
+       switch(imtype) {
+               case R_MOVIE:
+               case R_AVIRAW:
+               case R_AVIJPEG:
+               case R_AVICODEC:
+               case R_QUICKTIME:
+                       return 1;
        }
-       string[len]=0;
-       strcat(string,num);
-
-       if(G.scene->r.scemode & R_EXTENSION) 
-               addImageExtension(string);
-               
+       return 0;
 }
 
-void addImageExtension(char *string)
+void BKE_add_image_extension(char *string, int imtype)
 {
        char *extension="";
-
+       
        if(G.scene->r.imtype== R_IRIS) {
                if(!BLI_testextensie(string, ".rgb"))
                        extension= ".rgb";
        }
-       else if(G.scene->r.imtype==R_IRIZ) {
+       else if(imtype==R_IRIZ) {
                if(!BLI_testextensie(string, ".rgb"))
                        extension= ".rgb";
        }
-       else if(G.scene->r.imtype==R_RADHDR) {
+       else if(imtype==R_RADHDR) {
                if(!BLI_testextensie(string, ".hdr"))
                        extension= ".hdr";
        }
-       else if(G.scene->r.imtype==R_PNG) {
+       else if(imtype==R_PNG) {
                if(!BLI_testextensie(string, ".png"))
                        extension= ".png";
        }
-       else if(G.scene->r.imtype==R_TARGA) {
-               if(!BLI_testextensie(string, ".tga"))
-                       extension= ".tga";
-       }
-       else if(G.scene->r.imtype==R_RAWTGA) {
+       else if(imtype==R_RAWTGA) {
                if(!BLI_testextensie(string, ".tga"))
                        extension= ".tga";
        }
-       else if(G.scene->r.imtype==R_JPEG90) {
+       else if(ELEM5(imtype, R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90)) {
                if(!BLI_testextensie(string, ".jpg"))
                        extension= ".jpg";
        }
-       else if(G.scene->r.imtype==R_BMP) {
+       else if(imtype==R_BMP) {
                if(!BLI_testextensie(string, ".bmp"))
                        extension= ".bmp";
        }
-       else if(G.have_libtiff && (G.scene->r.imtype==R_TIFF)) {
+       else if(G.have_libtiff && (imtype==R_TIFF)) {
                if(!BLI_testextensie(string, ".tif"))
                        extension= ".tif";
        }
 #ifdef WITH_OPENEXR
-       else if(G.scene->r.imtype==R_OPENEXR) {
+       else if(imtype==R_OPENEXR) {
                if(!BLI_testextensie(string, ".exr"))
                        extension= ".exr";
        }
 #endif
-       
+       else {  /* targa default */
+               if(!BLI_testextensie(string, ".tga"))
+                       extension= ".tga";
+       }
+
        strcat(string, extension);
 }
 
 
+int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quality)
+{
+       int ok;
+       
+       if(imtype==0);
+       else if(imtype== R_IRIS) ibuf->ftype= IMAGIC;
+       else if ((imtype==R_RADHDR)) {
+               ibuf->ftype= RADHDR;
+       }
+       else if ((imtype==R_PNG)) {
+               ibuf->ftype= PNG;
+       }
+       else if ((imtype==R_BMP)) {
+               ibuf->ftype= BMP;
+       }
+       else if ((G.have_libtiff) && (imtype==R_TIFF)) {
+               ibuf->ftype= TIF;
+       }
+#ifdef WITH_OPENEXR
+       else if (imtype==R_OPENEXR) {
+               ibuf->ftype= OPENEXR;
+               if(subimtype & R_OPENEXR_HALF)
+                       ibuf->ftype |= OPENEXR_HALF;
+               ibuf->ftype |= (quality & OPENEXR_COMPRESS);
+               
+               if(!(subimtype & R_OPENEXR_ZBUF))
+                       ibuf->zbuf_float = NULL;        /* signal for exr saving */
+               
+       }
+#endif
+       else if (imtype==R_TARGA) {
+               ibuf->ftype= TGA;
+       }
+       else if(imtype==R_RAWTGA) {
+               ibuf->ftype= RAWTGA;
+       }
+       else if(imtype==R_HAMX) {
+               ibuf->ftype= AN_hamx;
+       }
+       else if ELEM(imtype, R_JPEG90, R_MOVIE) {
+               if(quality < 10) quality= 90;
+               ibuf->ftype= JPG|quality;
+       }
+       else ibuf->ftype= TGA;
+       
+       BLI_make_existing_file(name);
+       
+       ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
+       if (ok == 0) {
+               perror(name);
+       }
+       
+       return(ok);
+}
+
+
+void BKE_makepicstring(char *string, int frame)
+{
+       short i,len;
+       char num[10], *extension;
+
+       if (string==0) return;
+
+       extension= "";
+
+       strcpy(string, G.scene->r.pic);
+       BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
+
+       len= strlen(string);
+                       
+       /* can also: sprintf(num, "%04d", frame); */
+
+       i=4-sprintf(num,"%d",frame);
+       for(;i>0;i--){
+               string[len]='0';
+               len++;
+       }
+       string[len]=0;
+       strcat(string,num);
+
+       if(G.scene->r.scemode & R_EXTENSION) 
+               BKE_add_image_extension(string, G.scene->r.imtype);
+               
+}
+
 /* ******** IMAGE WRAPPING INIT ************* */
 
 /* used by sequencer, texture */
@@ -519,7 +589,6 @@ void ima_ibuf_is_nul(Tex *tex, Image *ima)
                if (ima->anim) {
                        dur = IMB_anim_get_duration(ima->anim);
                        
-                       ima->lastquality= R.osa;
                        fra= ima->lastframe-1;
                        
                        if(fra<0) fra = 0;
@@ -544,8 +613,6 @@ void ima_ibuf_is_nul(Tex *tex, Image *ima)
                load_image(ima, IB_rect, G.sce, G.scene->r.cfra);
                
                if (tex->imaflag & TEX_FIELDS) de_interlacefunc(ima->ibuf);
-               
-               ima->lastquality= R.osa;
        }
        
        if(ima->ibuf) {
@@ -573,14 +640,11 @@ void ima_ibuf_is_nul(Tex *tex, Image *ima)
                        converttopremul(ima->ibuf);
                }
                
-               if(R.osa) {
-                       
-                       if(tex->imaflag & TEX_ANTISCALE) {
-                               IMB_clever_double(ima->ibuf);
-                               IMB_antialias(ima->ibuf);
-                       }
-                       else if(tex->imaflag & TEX_ANTIALI) IMB_antialias(ima->ibuf);
+               if(tex->imaflag & TEX_ANTISCALE) {
+                       IMB_clever_double(ima->ibuf);
+                       IMB_antialias(ima->ibuf);
                }
+               else if(tex->imaflag & TEX_ANTIALI) IMB_antialias(ima->ibuf);
        }
        
        if(ima->ibuf)
index 60ba7f3cfebcd662917ddc555cb2281c3e850e40..b6b4f9a3bcbe1c46c97953fb9358c2008c5c8219 100644 (file)
@@ -57,6 +57,7 @@
 #include "DNA_sound_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_world_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
@@ -178,9 +179,9 @@ float frame_to_float(int cfra)              /* see also bsystem_time in object.c */
        float ctime;
        
        ctime= (float)cfra;
-       if(R.flag & R_SEC_FIELD) {
-               if((R.r.mode & R_FIELDSTILL)==0) ctime+= 0.5;
-       }
+//     if(R.flag & R_SEC_FIELD) {
+//             if((R.r.mode & R_FIELDSTILL)==0) ctime+= 0.5;
+//     }
        ctime+= bluroffs;
        ctime*= G.scene->r.framelen;
        
index a2e372f33d54df08b00003eafd74429379a86759..e0006c854cfe7ba8cf93b740cf8262b5f75e1df3 100644 (file)
@@ -45,6 +45,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+#include "DNA_scene_types.h"
 
 #include "BKE_action.h"
 #include "BKE_bad_level_calls.h"
index c617541e2254a1883049e55a88cfc36b495d90be..b95c401808df7bf27fa341c21aa8edc3dea9bc3a 100644 (file)
@@ -34,6 +34,8 @@
  */
 
 #include <string.h>
+#include <math.h>
+
 #include "MEM_guardedalloc.h"
 
 #include "DNA_curve_types.h"
 
 #include "BPY_extern.h"
 
+/* used in UI and render */
+Material defmaterial;
+
+/* called on startup, creator.c */
+void init_def_material(void)
+{
+       init_material(&defmaterial);
+}
+
 /* not material itself */
 void free_material(Material *ma)
 {
-       MaterialLayer *ml;
        MTex *mtex;
        int a;
 
@@ -81,11 +91,6 @@ void free_material(Material *ma)
        
        BKE_icon_delete((struct ID*)ma);
        ma->id.icon_id = 0;
-
-       for(ml= ma->layers.first; ml; ml= ml->next)
-               if(ml->mat) ml->mat->id.us--;
-       
-       BLI_freelistN(&ma->layers);
        
        /* is no lib link block, but material extension */
        if(ma->nodetree) {
@@ -134,7 +139,6 @@ void init_material(Material *ma)
        ma->rampfac_col= 1.0;
        ma->rampfac_spec= 1.0;
        ma->pr_lamp= 3;                 /* two lamps, is bits */
-       ma->ml_flag= ML_RENDER; /* default render base material for layers */
 
        ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR;
 }
@@ -153,7 +157,6 @@ Material *add_material(char *name)
 Material *copy_material(Material *ma)
 {
        Material *man;
-       MaterialLayer *ml;
        int a;
        
        man= copy_libblock(ma);
@@ -173,10 +176,6 @@ Material *copy_material(Material *ma)
        if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
        if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
        
-       duplicatelist(&man->layers, &ma->layers);
-       for(ml= man->layers.first; ml; ml= ml->next)
-               id_us_plus((ID *)ml->mat);
-
        if(ma->nodetree) {
                man->nodetree= ntreeCopyTree(ma->nodetree, 0);  /* 0 == full new tree */
        }
@@ -274,25 +273,10 @@ void make_local_material(Material *ma)
                new_id(0, (ID *)ma, 0);
        }
        else if(local && lib) {
-               Material *mat;
-               MaterialLayer *ml;
                
                man= copy_material(ma);
                man->id.us= 0;
                
-               /* do material layers */
-               for(mat= G.main->mat.first; mat; mat= mat->id.next) {
-                       if(mat->id.lib==NULL) {
-                               for(ml= mat->layers.first; ml; ml= ml->next) {
-                                       if(ml->mat==ma) {
-                                               ml->mat= man;
-                                               man->id.us++;
-                                               ma->id.us--;
-                                       }
-                               }
-                       }
-               }
-               
                /* do objects */
                ob= G.main->object.first;
                while(ob) {
@@ -579,7 +563,7 @@ void new_material_to_objectdata(Object *ob)
        ob->actcol= ob->totcol;
 }
 
-static void do_init_render_material(Material *ma)
+static void do_init_render_material(Material *ma, int osa, float *amb)
 {
        MTex *mtex;
        int a, needuv=0;
@@ -595,48 +579,41 @@ static void do_init_render_material(Material *ma)
                        
                        ma->texco |= mtex->texco;
                        ma->mapto |= mtex->mapto;
-                       if(R.osa) {
+                       if(osa) {
                                if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA;
                        }
                        
                        if(ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1;
                        else if(ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT)) needuv= 1;
                        else if(ma->texco & (TEXCO_LAVECTOR|TEXCO_VIEW|TEXCO_STICKY)) needuv= 1;
-                       
-                       if(mtex->object) mtex->object->flag |= OB_DO_IMAT;
-                       
                }
        }
-       if(ma->mode & MA_ZTRA) {
-               /* if(ma->alpha==0.0 || ma->alpha==1.0) */
-               if(R.flag & R_RENDERING) R.flag |= R_ZTRA;
-       }
        
        if(ma->mode & MA_RADIO) needuv= 1;
        
        if(ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) {
                needuv= 1;
-               if(R.osa) ma->texco |= TEXCO_OSA;               /* for texfaces */
+               if(osa) ma->texco |= TEXCO_OSA;         /* for texfaces */
        }
        if(needuv) ma->texco |= NEED_UV;
        
        // 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;
-               if(R.osa) ma->texco |= TEXCO_OSA;
+               if(osa) ma->texco |= TEXCO_OSA;
        }
 
-       ma->ambr= ma->amb*R.wrld.ambr;
-       ma->ambg= ma->amb*R.wrld.ambg;
-       ma->ambb= ma->amb*R.wrld.ambb;
+       ma->ambr= ma->amb*amb[0];
+       ma->ambg= ma->amb*amb[1];
+       ma->ambb= ma->amb*amb[2];
        
-       /* will become or-ed result of all layer modes */
+       /* will become or-ed result of all node modes */
        ma->mode_l= ma->mode;
 }
 
-void init_render_material(Material *mat)
+void init_render_material(Material *mat, int osa, float *amb)
 {
-       do_init_render_material(mat);
+       do_init_render_material(mat, osa, amb);
        
        if(mat->nodetree && mat->use_nodes) {
                bNode *node;
@@ -645,26 +622,26 @@ void init_render_material(Material *mat)
                        if(node->id && GS(node->id->name)==ID_MA) {
                                Material *ma= (Material *)node->id;
                                if(ma!=mat) {
-                                       do_init_render_material(ma);
+                                       do_init_render_material(ma, osa, amb);
                                        mat->texco |= ma->texco;
                                        mat->mode_l |= ma->mode_l;
                                }
                        }
                }
                /* parses the geom nodes */
-               mat->texco |= ntreeShaderGetTexco(mat->nodetree);
+               mat->texco |= ntreeShaderGetTexco(mat->nodetree, osa);
                ntreeBeginExecTree(mat->nodetree); /* has internal flag to detect it only does it once */
        }
 }
 
-void init_render_materials()
+void init_render_materials(int osa, float *amb)
 {
        Material *ma;
        
        /* two steps, first initialize, then or the flags for layers */
        for(ma= G.main->mat.first; ma; ma= ma->id.next)
                if(ma->id.us) 
-                       init_render_material(ma);
+                       init_render_material(ma, osa, amb);
 }
 
 /* only needed for nodes now */
@@ -815,3 +792,89 @@ void delete_material_index()
                freedisplist(&ob->disp);
        }
 }
+
+
+/* r g b = current value, col = new value, fac==0 is no change */
+/* if g==NULL, it only does r channel */
+void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
+{
+       float tmp, facm= 1.0-fac;
+       
+       switch (type) {
+               case MA_RAMP_BLEND:
+                       *r = facm*(*r) + fac*col[0];
+                       if(g) {
+                               *g = facm*(*g) + fac*col[1];
+                               *b = facm*(*b) + fac*col[2];
+                       }
+                               break;
+               case MA_RAMP_ADD:
+                       *r += fac*col[0];
+                       if(g) {
+                               *g += fac*col[1];
+                               *b += fac*col[2];
+                       }
+                               break;
+               case MA_RAMP_MULT:
+                       *r *= (facm + fac*col[0]);
+                       if(g) {
+                               *g *= (facm + fac*col[1]);
+                               *b *= (facm + fac*col[2]);
+                       }
+                               break;
+               case MA_RAMP_SCREEN:
+                       *r = 1.0 - (facm + fac*(1.0 - col[0])) * (1.0 - *r);
+                       if(g) {
+                               *g = 1.0 - (facm + fac*(1.0 - col[1])) * (1.0 - *g);
+                               *b = 1.0 - (facm + fac*(1.0 - col[2])) * (1.0 - *b);
+                       }
+                               break;
+               case MA_RAMP_SUB:
+                       *r -= fac*col[0];
+                       if(g) {
+                               *g -= fac*col[1];
+                               *b -= fac*col[2];
+                       }
+                               break;
+               case MA_RAMP_DIV:
+                       if(col[0]!=0.0)
+                               *r = facm*(*r) + fac*(*r)/col[0];
+                       if(g) {
+                               if(col[1]!=0.0)
+                                       *g = facm*(*g) + fac*(*g)/col[1];
+                               if(col[2]!=0.0)
+                                       *b = facm*(*b) + fac*(*b)/col[2];
+                       }
+                               break;
+               case MA_RAMP_DIFF:
+                       *r = facm*(*r) + fac*fabs(*r-col[0]);
+                       if(g) {
+                               *g = facm*(*g) + fac*fabs(*g-col[1]);
+                               *b = facm*(*b) + fac*fabs(*b-col[2]);
+                       }
+                               break;
+               case MA_RAMP_DARK:
+                       tmp= fac*col[0];
+                       if(tmp < *r) *r= tmp; 
+                               if(g) {
+                                       tmp= fac*col[1];
+                                       if(tmp < *g) *g= tmp; 
+                                       tmp= fac*col[2];
+                                       if(tmp < *b) *b= tmp; 
+                               }
+                                       break;
+               case MA_RAMP_LIGHT:
+                       tmp= fac*col[0];
+                       if(tmp > *r) *r= tmp; 
+                               if(g) {
+                                       tmp= fac*col[1];
+                                       if(tmp > *g) *g= tmp; 
+                                       tmp= fac*col[2];
+                                       if(tmp > *b) *b= tmp; 
+                               }
+                                       break;
+       }
+       
+}
+
+
index 09408e4a220af9a3b5b1ee9903fb50b5b2f3c79a..9429183105b10e5445871d0c4ca69ea5e12be3e2 100644 (file)
@@ -30,8 +30,6 @@
  * 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): Jiri Hnidek <jiri.hnidek@vslib.cz>.
  *
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
@@ -1106,7 +1104,6 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v)
        }
        
        if(FALSE) {
-       /* if(R.flag & R_RENDERING) { */
                MB_POINT temp;
                
                delta*= 2.0;
@@ -2002,7 +1999,7 @@ void metaball_polygonize(Object *ob)
        mb= ob->data;
 
        if(totelem==0) return;
-       if(!(R.flag & R_RENDERING) && (mb->flag==MB_UPDATE_NEVER)) return;
+       if(!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return;
        if(G.moving && mb->flag==MB_UPDATE_FAST) return;
 
        freedisplist(&ob->disp);
@@ -2029,7 +2026,7 @@ void metaball_polygonize(Object *ob)
        if(totelem > 1024) init_metaball_octal_tree(5);
 
        /* width is size per polygonize cube */
-       if(R.flag & R_RENDERING) width= mb->rendersize;
+       if(G.rendering) width= mb->rendersize;
        else {
                width= mb->wiresize;
                if(G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2;
index da18725c2ddaa0a181c7601efa098bdf3e8ff557..f7d0be1ac33002167b31655a41b5eb0963019e36 100644 (file)
@@ -47,6 +47,7 @@
 #include "BLI_blenlib.h"
 
 #include "MEM_guardedalloc.h"
+#include "IMB_imbuf.h"
 
 /* not very important, but the stack solver likes to know a maximum */
 #define MAX_SOCKET     64
@@ -77,6 +78,8 @@ void ntreeInitTypes(bNodeTree *ntree)
        
        if(ntree->type==NTREE_SHADER)
                ntree->alltypes= node_all_shaders;
+       else if(ntree->type==NTREE_COMPOSIT)
+               ntree->alltypes= node_all_composit;
        else {
                ntree->alltypes= NULL;
                printf("Error: no type definitions for nodes\n");
@@ -702,6 +705,14 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
                else if(type==SH_NODE_CURVE_RGB)
                        node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
        }
+       else if(ntree->type==NTREE_COMPOSIT) {
+               if(type==CMP_NODE_VALTORGB)
+                       node->storage= add_colorband(1);
+               else if(type==CMP_NODE_CURVE_VEC)
+                       node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
+               else if(type==CMP_NODE_CURVE_RGB)
+                       node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
+       }
        
        return node;
 }
@@ -735,6 +746,12 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
                        else 
                                nnode->storage= MEM_dupallocN(nnode->storage);
                }
+               else if(ntree->type==NTREE_COMPOSIT) {
+                       if(node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)
+                               nnode->storage= curvemapping_copy(node->storage);
+                       else 
+                               nnode->storage= MEM_dupallocN(nnode->storage);
+               }
                else 
                        nnode->storage= MEM_dupallocN(nnode->storage);
        }
@@ -832,6 +849,12 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
                        else 
                                MEM_freeN(node->storage);
                }
+               else if(ntree->type==NTREE_COMPOSIT) {
+                       if(node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB)
+                               curvemapping_free(node->storage);
+                       else 
+                               MEM_freeN(node->storage);
+               }
                else 
                        MEM_freeN(node->storage);
        }
@@ -843,6 +866,8 @@ void ntreeFreeTree(bNodeTree *ntree)
 {
        bNode *node, *next;
        
+       if(ntree==NULL) return;
+       
        BLI_freelistN(&ntree->links);   /* do first, then unlink_node goes fast */
        
        for(node= ntree->nodes.first; node; node= next) {
@@ -1070,6 +1095,9 @@ void ntreeSolveOrder(bNodeTree *ntree)
        bNodeLink *link;
        int a, totnode=0;
        
+       /* the solve-order is called on each tree change, so we should be sure no exec can be running */
+       ntreeEndExecTree(ntree);
+
        /* set links pointers the input sockets, to find dependencies */
        /* first clear data */
        for(node= ntree->nodes.first; node; node= node->next) {
@@ -1110,8 +1138,8 @@ void ntreeSolveOrder(bNodeTree *ntree)
        MEM_freeN(nodesort);
        
        /* find the active outputs, tree type dependant, might become handler */
-       if(ntree->type==NTREE_SHADER) {
-               /* shader nodes only accepts one output */
+       if(ntree->type==NTREE_SHADER || ntree->type==NTREE_COMPOSIT) {
+               /* shader/composit nodes only accepts one output */
                int output= 0;
                
                for(node= ntree->nodes.first; node; node= node->next) {
@@ -1127,9 +1155,6 @@ void ntreeSolveOrder(bNodeTree *ntree)
        
        /* here we could recursively set which nodes have to be done,
                might be different for editor or for "real" use... */
-       
-       
-       
 }
 
 #pragma mark /* *************** preview *********** */
@@ -1138,12 +1163,9 @@ void ntreeSolveOrder(bNodeTree *ntree)
 
 static void nodeInitPreview(bNode *node, int xsize, int ysize)
 {
-       /* signal we don't do anything, preview writing is protected */
-       if(xsize==0 || ysize==0)
-               return;
        
        /* sanity checks & initialize */
-       if(node->preview) {
+       if(node->preview && node->preview->rect) {
                if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
                        MEM_freeN(node->preview->rect);
                        node->preview->rect= NULL;
@@ -1154,6 +1176,11 @@ static void nodeInitPreview(bNode *node, int xsize, int ysize)
                node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
                printf("added preview %s\n", node->name);
        }
+       
+       /* node previews can get added with variable size this way */
+       if(xsize==0 || ysize==0)
+               return;
+
        if(node->preview->rect==NULL) {
                node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
                node->preview->xsize= xsize;
@@ -1293,17 +1320,31 @@ static int ntree_begin_exec_tree(bNodeTree *ntree)
 
 void ntreeBeginExecTree(bNodeTree *ntree)
 {
-       int index;
        
        /* goes recursive over all groups */
-       index= ntree_begin_exec_tree(ntree);
+       ntree->stacksize= ntree_begin_exec_tree(ntree);
        
-       if(index) {
+       if(ntree->stacksize) {
+               bNode *node;
                bNodeStack *ns;
                int a;
                
-               ns=ntree->stack= MEM_callocN(index*sizeof(bNodeStack), "node stack");
-               for(a=0; a<index; a++, ns++) ns->hasinput= 1;
+               /* allocate stack */
+               ns=ntree->stack= MEM_callocN(ntree->stacksize*sizeof(bNodeStack), "node stack");
+               
+               /* tag inputs, the get_stack() gives own socket stackdata if not in use */
+               for(a=0; a<ntree->stacksize; a++, ns++) ns->hasinput= 1;
+               
+               /* tag outputs, so we know when we can skip operations */
+               for(node= ntree->nodes.first; node; node= node->next) {
+                       bNodeSocket *sock;
+                       for(sock= node->inputs.first; sock; sock= sock->next) {
+                               if(sock->link) {
+                                       ns= ntree->stack + sock->link->fromsock->stack_index;
+                                       ns->hasoutput= 1;
+                               }
+                       }
+               }
                
                ntree->stack1= MEM_dupallocN(ntree->stack);
        }
@@ -1315,7 +1356,21 @@ void ntreeEndExecTree(bNodeTree *ntree)
 {
        
        if(ntree->init & NTREE_EXEC_INIT) {
+               
                if(ntree->stack) {
+                       
+                       /* another callback candidate! */
+                       if(ntree->type==NTREE_COMPOSIT) {
+                               bNodeStack *ns;
+                               int a;
+                               
+                               for(ns= ntree->stack, a=0; a<ntree->stacksize; a++, ns++)
+                                       if(ns->data)
+                                               free_compbuf(ns->data);
+                               for(ns= ntree->stack1, a=0; a<ntree->stacksize; a++, ns++)
+                                       if(ns->data)
+                                               free_compbuf(ns->data);
+                       }
                        MEM_freeN(ntree->stack);
                        ntree->stack= NULL;
                        MEM_freeN(ntree->stack1);
@@ -1352,37 +1407,23 @@ void ntreeExecTree(bNodeTree *ntree, void *callerdata, int thread)
        bNodeStack *stack;
        
        /* only when initialized */
-       if(ntree->init & NTREE_EXEC_INIT) {
-               
-               if(thread)
-                       stack= ntree->stack1;
-               else
-                       stack= ntree->stack;
+       if((ntree->init & NTREE_EXEC_INIT)==0)
+               ntreeBeginExecTree(ntree);
                
-               for(node= ntree->nodes.first; node; node= node->next) {
-                       if(node->typeinfo->execfunc) {
-                               node_get_stack(node, stack, nsin, nsout);
-                               node->typeinfo->execfunc(callerdata, node, nsin, nsout);
-                       }
-                       else if(node->type==NODE_GROUP && node->id) {
-                               node_get_stack(node, stack, nsin, nsout);
-                               node_group_execute(stack, callerdata, node, nsin, nsout); 
-                       }
-               }
-       }
-}
-
-/* clear one pixel in all the preview images */
-void ntreeClearPixelTree(bNodeTree *ntree, int x, int y)
-{
-       bNode *node;
-       float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+       if(thread)
+               stack= ntree->stack1;
+       else
+               stack= ntree->stack;
        
-       /* only when initialized */
-       if(ntree->init & NTREE_EXEC_INIT) {
-               for(node= ntree->nodes.first; node; node= node->next) {
-                       if(node->preview)
-                               nodeAddToPreview(node, vec, x, y);
+       for(node= ntree->nodes.first; node; node= node->next) {
+               if(node->typeinfo->execfunc) {
+                       node_get_stack(node, stack, nsin, nsout);
+                       node->typeinfo->execfunc(callerdata, node, nsin, nsout);
+               }
+               else if(node->type==NODE_GROUP && node->id) {
+                       node_get_stack(node, stack, nsin, nsout);
+                       node_group_execute(stack, callerdata, node, nsin, nsout); 
                }
        }
 }
+
diff --git a/source/blender/blenkernel/intern/node_composit.c b/source/blender/blenkernel/intern/node_composit.c
new file mode 100644 (file)
index 0000000..b7d70b1
--- /dev/null
@@ -0,0 +1,1372 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "DNA_ID.h"
+#include "DNA_image_types.h"
+#include "DNA_node_types.h"
+#include "DNA_material_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_vec_types.h"
+
+#include "BKE_blender.h"
+#include "BKE_colortools.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_node.h"
+#include "BKE_material.h"
+#include "BKE_texture.h"
+#include "BKE_utildefines.h"
+
+#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+
+#include "MEM_guardedalloc.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "RE_pipeline.h"
+
+/* *************************** operations support *************************** */
+
+/* general signal that's in output sockets, and goes over the wires */
+typedef struct CompBuf {
+       float *rect;
+       int x, y;
+       short type, malloc;
+       rcti disprect;          /* cropped part of image */
+       int xof, yof;           /* relative to center of target image */
+} CompBuf;
+
+/* defines also used for pixel size */
+#define CB_RGBA                4
+#define CB_VAL         1
+
+static CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc)
+{
+       CompBuf *cbuf= MEM_callocN(sizeof(CompBuf), "compbuf");
+       
+       cbuf->x= sizex;
+       cbuf->y= sizey;
+       cbuf->type= type;
+       if(alloc) {
+               if(cbuf->type==CB_RGBA)
+                       cbuf->rect= MEM_mallocN(4*sizeof(float)*sizex*sizey, "new rect");
+               else
+                       cbuf->rect= MEM_mallocN(sizeof(float)*sizex*sizey, "new rect");
+               cbuf->malloc= 1;
+       }
+       cbuf->disprect.xmin= 0;
+       cbuf->disprect.ymin= 0;
+       cbuf->disprect.xmax= sizex;
+       cbuf->disprect.ymax= sizey;
+       
+       return cbuf;
+}
+
+void free_compbuf(CompBuf *cbuf)
+{
+       if(cbuf->malloc && cbuf->rect)
+               MEM_freeN(cbuf->rect);
+       MEM_freeN(cbuf);
+}
+
+#if 0
+/* on first call, disprect should be initialized to 'out', then you can call this on all 'src' images */
+static void get_overlap_rct(CompBuf *out, CompBuf *src, rcti *disprect)
+{
+       rcti rect;
+       /* output center is considered (0,0) */
+       
+       if(src==NULL) return;
+       
+       /* translate src into output space */
+       rect= src->disprect;
+       BLI_translate_rcti(&rect, out->xof-src->xof, out->xof-src->xof);
+       /* intersect rect with current disprect */
+       
+       BLI_isect_rcti(&rect, disprect, disprect);
+}
+
+static void get_scanline_rcti(CompBuf *out, rcti *disprect, CompBuf *src, rcti *srcrect)
+{
+       int xof, yof;
+       
+       /* translate src into output space */
+       xof= out->xof-src->xof;
+       yof= out->xof-src->xof;
+       
+       srcrect->xmin= disprect->xmin + xof;
+       srcrect->ymin= disprect->ymin + yof;
+       srcrect->xmax= disprect->xmax + xof;
+       srcrect->ymax= disprect->ymax + yof;
+}
+#endif
+
+/* Pixel-to-Pixel operation, 1 Image in, 1 out */
+static void composit1_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, float *src_col,
+                                                                         void (*func)(bNode *, float *, float *))
+{
+       float *outfp, *srcfp, *out_data, *src_data;
+       int outx, outy;
+       int srcx, srcy;
+       int out_pix, out_stride, src_stride, src_pix, x, y;
+       
+       outx= out->x;
+       outy= out->y;
+       out_pix= out->type;
+       out_stride= out->x;
+       out_data= out->rect;
+       
+       /* handle case when input is constant color */
+       if(src_buf==NULL) {
+               srcx= outx; srcy= outy;
+               src_stride= 0;
+               src_pix= 0;
+               src_data= src_col;
+       }
+       else {
+               srcx= src_buf->x;
+               srcy= src_buf->y;
+               src_stride= srcx;
+               src_pix= src_buf->type;
+               src_data= src_buf->rect;
+       }
+       
+       outx= MIN2(outx, srcx);
+       outy= MIN2(outy, srcy);
+
+       for(y=0; y<outy; y++) {
+               /* set scanlines on right location */
+               srcfp= src_data + src_pix*y*src_stride;
+               outfp= out_data + out_pix*y*out_stride;
+                       
+               for(x=0; x<outx; x++) {
+                       func(node, outfp, srcfp);
+                       srcfp += src_pix;
+                       outfp += out_pix;
+               }
+       }
+}
+
+/* Pixel-to-Pixel operation, 2 Images in, 1 out */
+static void composit2_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, float *src_col,
+                                                                         CompBuf *fac_buf, float *fac, void (*func)(bNode *, float *, float *, float *))
+{
+       float *outfp, *srcfp, *src_data, *facfp, *fac_data;
+       int outx= out->x, outy= out->y;
+       int srcx, srcy, facx, facy;
+       int out_pix, src_stride, src_pix, fac_stride, fac_pix, x, y;
+       
+       out_pix= out->type;
+       
+       /* handle case when input is constant color */
+       if(src_buf==NULL) {
+               srcx= outx; srcy= outy;
+               src_stride= 0;
+               src_pix= 0;
+               src_data= src_col;
+       }
+       else {
+               srcx= src_buf->x;
+               srcy= src_buf->y;
+               src_stride= srcx;
+               src_pix= src_buf->type;
+               src_data= src_buf->rect;
+       }
+       
+       /* factor buf or constant? */
+       if(fac_buf==NULL) {
+               facx= outx; facy= outy;
+               fac_stride= 0;
+               fac_pix= 0;
+               fac_data= fac;
+       }
+       else {
+               facx= fac_buf->x;
+               facy= fac_buf->y;
+               fac_stride= facx;
+               fac_pix= src_buf->type;
+               fac_data= fac_buf->rect;
+       }
+       
+       if(fac_data==NULL) {
+               printf("fac buffer error, node %s\n", node->name);
+               return;
+       }
+       
+       facx= MIN2(facx, srcx);
+       facy= MIN2(facy, srcy);
+       
+#if 0  
+       if(src_buf) {
+               rcti disprect;
+               
+               disprect= out->disprect;
+               get_overlap_rct(out, src_buf, &disprect);
+               printf("%s\n", node->name);
+               printf("union %d %d %d %d\n", disprect.xmin,disprect.ymin,disprect.xmax,disprect.ymax);
+       }
+       /* new approach */
+       outfp= out->rect_float + src.ymin*outx + ;
+       for(y=src.ymin; y<src.ymax; y++) {
+               
+               /* all operators available */
+               if(y>=disp.ymin && y<disp.ymax) {
+                       srcfp= src_data + (src_stride*(y+scrc.ymin) + src.xmin);
+                       facfp= fac_data + (fac_stride*(y+fac.ymin) + fac.xmin);
+                       
+                       for(x= src.xmin; x<src.xmax; x++) {
+                               if(x>=disp.xmin && x<disp.xmax) {
+                                       
+                                       srcfp+= src_pix;
+                                       facfp+= fac_pix;
+                               }
+                               else {
+                                       /* copy src1 */
+                               }
+                       }
+               }
+               else {
+                       /* copy src1 */
+                       srcfp= src_data + (src_stride*(y+scrc.ymin) + src.xmin);
+                       
+                       QUATCOPY(outfp, srcfp);
+               }
+       }       
+#endif
+       
+       outfp= out->rect;
+       for(y=0; y<outy; y++) {
+               /* set source scanline on right location */
+               srcfp= src_data + src_pix*y*src_stride;
+               facfp= fac_data + fac_pix*y*fac_stride;
+               
+               for(x=0; x<outx; x++, outfp+=out_pix) {
+                       if(x<facx && y<facy)
+                               func(node, outfp, srcfp, facfp);
+                       srcfp += src_pix;
+                       facfp += fac_pix;
+               }
+       }
+}
+
+/* Pixel-to-Pixel operation, 3 Images in, 1 out */
+static void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, float *src1_col, CompBuf *src2_buf, float *src2_col, 
+                                                                         CompBuf *fac_buf, float fac, void (*func)(bNode *, float *, float *, float *, float))
+{
+       float *outfp, *src1fp, *src2fp, *facfp, *src1_data, *src2_data, *fac_data;
+       int outx= out->x, outy= out->y;
+       int src1x, src1y, src2x, src2y, facx, facy;
+       int src1_stride, src1_pix, src2_stride, src2_pix, fac_stride, fac_pix, x, y;
+
+       /* handle case when input has constant color */
+       if(src1_buf==NULL) {
+               src1x= outx; src1y= outy;
+               src1_stride= 0;
+               src1_pix= 0;
+               src1_data= src1_col;
+       }
+       else {
+               src1x= src1_buf->x;
+               src1y= src1_buf->y;
+               src1_stride= src1x;
+               src1_pix= src1_buf->type;
+               src1_data= src1_buf->rect;
+       }
+       
+       if(src2_buf==NULL) {
+               src2x= outx; src2y= outy;
+               src2_stride= 0;
+               src2_pix= 0;
+               src2_data= src2_col;
+       }
+       else {
+               src2x= src2_buf->x;
+               src2y= src2_buf->y;
+               src2_stride= src2x;
+               src2_pix= src2_buf->type;
+               src2_data= src2_buf->rect;
+       }
+       
+       /* factor buf or constant? */
+       if(fac_buf==NULL) {
+               facx= outx; facy= outy;
+               fac_stride= 0;
+               fac_pix= 0;
+               fac_data= &fac;
+       }
+       else {
+               facx= fac_buf->x;
+               facy= fac_buf->y;
+               fac_stride= facx;
+               fac_pix= 1;
+               fac_data= fac_buf->rect;
+       }
+       
+       facx= MIN3(facx, src1x, src2x);
+       facy= MIN3(facy, src1y, src2y);
+       
+       outfp= out->rect;
+       for(y=0; y<outy; y++) {
+               
+               /* set source scanlines on right location */
+               src1fp= src1_data + src1_pix*y*src1_stride;
+               src2fp= src2_data + src2_pix*y*src2_stride;
+               facfp= fac_data + y*fac_stride;
+               
+               for(x=0; x<outx; x++, outfp+=4) {
+                       if(x<facx && y<facy)
+                               func(node, outfp, src1fp, src2fp, *facfp);
+                       src1fp+= src1_pix;
+                       src2fp+= src2_pix;
+                       facfp+= fac_pix;
+               }
+       }
+}
+
+/*  */
+static CompBuf *alphabuf_from_rgbabuf(CompBuf *cbuf)
+{
+       CompBuf *valbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1);
+       float *valf, *rectf;
+       int tot;
+       
+       valf= valbuf->rect;
+       rectf= cbuf->rect + 3;
+       for(tot= cbuf->x*cbuf->y; tot>0; tot--, valf++, rectf+=4)
+               *valf= *rectf;
+       
+       return valbuf;
+}
+
+static void generate_preview(bNode *node, CompBuf *stackbuf)
+{
+       bNodePreview *preview= node->preview;
+       
+       if(preview) {
+               ImBuf *ibuf= IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0, 0);        /* empty */
+               
+               if(stackbuf->x > stackbuf->y) {
+                       preview->xsize= 140;
+                       preview->ysize= (140*stackbuf->y)/stackbuf->x;
+               }
+               else {
+                       preview->ysize= 140;
+                       preview->xsize= (140*stackbuf->x)/stackbuf->y;
+               }
+               ibuf->rect_float= stackbuf->rect;
+               ibuf= IMB_scalefastImBuf(ibuf, preview->xsize, preview->ysize);
+               
+               /* this ensures free-imbuf does the right stuff */
+               SWAP(float *, ibuf->rect_float, node->preview->rect);
+               
+               IMB_freeImBuf(ibuf);
+       }
+}
+
+/* ******************************************************** */
+/* ********* Composit Node type definitions ***************** */
+/* ******************************************************** */
+
+/* SocketType syntax: 
+   socket type, max connections (0 is no limit), name, 4 values for default, 2 values for range */
+
+/* Verification rule: If name changes, a saved socket and its links will be removed! Type changes are OK */
+
+/* **************** OUTPUT ******************** */
+static bNodeSocketType cmp_node_output_in[]= {
+       {       SOCK_RGBA, 1, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 1, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_copy_rgba(bNode *node, float *out, float *in)
+{
+       QUATCOPY(out, in);
+}
+static void do_copy_a_rgba(bNode *node, float *out, float *in, float *fac)
+{
+       VECCOPY(out, in);
+       out[3]= *fac;
+}
+
+static void node_composit_exec_output(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* image assigned to output */
+       /* stack order input sockets: col, alpha */
+       
+       if(node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
+               Image *ima= (Image *)node->id;
+               CompBuf *cbuf;
+               int rectx, recty;
+               
+               /* scene size? */
+               if(1) {
+                       /* re-create output, derive size from scene */
+                       rectx= (G.scene->r.size*G.scene->r.xsch)/100;
+                       recty= (G.scene->r.size*G.scene->r.ysch)/100;
+                       
+                       if(ima->ibuf) IMB_freeImBuf(ima->ibuf);
+                       ima->ibuf= IMB_allocImBuf(rectx, recty, 32, IB_rectfloat, 0); // do alloc
+                       
+                       cbuf= alloc_compbuf(rectx, recty, CB_RGBA, 0);  // no alloc
+                       cbuf->rect= ima->ibuf->rect_float;
+               
+                       /* when no alpha, we can simply copy */
+                       if(in[1]->data==NULL)
+                               composit1_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, do_copy_rgba);
+                       else
+                               composit2_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba);
+                       
+                       generate_preview(node, cbuf);
+                       free_compbuf(cbuf);
+               }
+               else { /* test */
+                       if(ima->ibuf) IMB_freeImBuf(ima->ibuf);
+                       ima->ibuf= IMB_allocImBuf(rectx, recty, 32, 0, 0); // do alloc
+                       ima->ibuf->mall= IB_rectfloat;
+                       cbuf= in[0]->data;
+                       ima->ibuf->rect_float= cbuf->rect;
+                       ima->ibuf->x= cbuf->x;
+                       ima->ibuf->y= cbuf->y;
+                       cbuf->rect= NULL;
+               }
+               
+       }
+       else if(in[0]->data)
+               generate_preview(node, in[0]->data);
+}
+
+static bNodeType cmp_node_output= {
+       /* type code   */       CMP_NODE_OUTPUT,
+       /* name        */       "Output",
+       /* width+range */       80, 60, 200,
+       /* class+opts  */       NODE_CLASS_OUTPUT, NODE_PREVIEW,
+       /* input sock  */       cmp_node_output_in,
+       /* output sock */       NULL,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_output
+       
+};
+
+/* **************** IMAGE ******************** */
+static bNodeSocketType cmp_node_image_out[]= {
+       {       SOCK_RGBA, 0, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 0, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 0, "Z",                     1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_composit_exec_image(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* image assigned to output */
+       /* stack order input sockets: col, alpha */
+       if(node->id) {
+               Image *ima= (Image *)node->id;
+               CompBuf *stackbuf;
+               
+               /* test if image is OK */
+               if(ima->ok==0) return;
+               if(ima->ibuf==NULL) {
+                       load_image(ima, IB_rect, G.sce, G.scene->r.cfra);
+                       if(ima->ibuf==NULL) {
+                               ima->ok= 0;
+                               return;
+                       }
+               }
+               if(ima->ibuf->rect_float==NULL)
+                       IMB_float_from_rect(ima->ibuf);
+               
+               /* we put imbuf copy on stack, cbuf knows rect is from other ibuf when freed! */
+               stackbuf= alloc_compbuf(ima->ibuf->x, ima->ibuf->y, CB_RGBA, 0);
+               stackbuf->rect= ima->ibuf->rect_float;
+               
+               /* put ibuf on stack */ 
+               out[0]->data= stackbuf;
+               
+               if(out[1]->hasoutput)
+                       out[1]->data= alphabuf_from_rgbabuf(stackbuf);
+               
+               generate_preview(node, stackbuf);
+       }       
+}
+
+static bNodeType cmp_node_image= {
+       /* type code   */       CMP_NODE_IMAGE,
+       /* name        */       "Image",
+       /* width+range */       120, 80, 300,
+       /* class+opts  */       NODE_CLASS_GENERATOR, NODE_PREVIEW|NODE_OPTIONS,
+       /* input sock  */       NULL,
+       /* output sock */       cmp_node_image_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_image
+       
+};
+
+/* **************** RENDER RESULT ******************** */
+static bNodeSocketType cmp_node_rresult_out[]= {
+       {       SOCK_RGBA, 0, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 0, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 0, "Z",                     1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_composit_exec_rresult(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       RenderResult *rr= RE_GetResult(RE_GetRender("Render"));
+       if(rr) {
+               RenderLayer *rl= rr->layers.first;
+               CompBuf *stackbuf;
+               
+               /* we put render rect on stack, cbuf knows rect is from other ibuf when freed! */
+               stackbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 0);
+               stackbuf->rect= rl->rectf;
+               
+               /* put on stack */      
+               out[0]->data= stackbuf;
+               
+               if(out[1]->hasoutput)
+                       out[1]->data= alphabuf_from_rgbabuf(stackbuf);
+               
+               generate_preview(node, stackbuf);
+       }       
+}
+
+static bNodeType cmp_node_rresult= {
+       /* type code   */       CMP_NODE_R_RESULT,
+       /* name        */       "Render Result",
+       /* width+range */       120, 80, 300,
+       /* class+opts  */       NODE_CLASS_GENERATOR, NODE_PREVIEW,
+       /* input sock  */       NULL,
+       /* output sock */       cmp_node_rresult_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_rresult
+       
+};
+
+/* **************** NORMAL  ******************** */
+static bNodeSocketType cmp_node_normal_in[]= {
+       {       SOCK_VECTOR, 1, "Normal",       0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketType cmp_node_normal_out[]= {
+       {       SOCK_VECTOR, 0, "Normal",       0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
+       {       SOCK_VALUE, 0, "Dot",           1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+/* generates normal, does dot product */
+static void node_composit_exec_normal(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       bNodeSocket *sock= node->outputs.first;
+       /* stack order input:  normal */
+       /* stack order output: normal, value */
+       
+       VECCOPY(out[0]->vec, sock->ns.vec);
+       /* render normals point inside... the widget points outside */
+       out[1]->vec[0]= -INPR(out[0]->vec, in[0]->vec);
+}
+
+static bNodeType cmp_node_normal= {
+       /* type code   */       CMP_NODE_NORMAL,
+       /* name        */       "Normal",
+       /* width+range */       100, 60, 200,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_normal_in,
+       /* output sock */       cmp_node_normal_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_normal
+       
+};
+
+/* **************** CURVE VEC  ******************** */
+static bNodeSocketType cmp_node_curve_vec_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",       0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketType cmp_node_curve_vec_out[]= {
+       {       SOCK_VECTOR, 0, "Vector",       0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_composit_exec_curve_vec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order input:  vec */
+       /* stack order output: vec */
+       
+       curvemapping_evaluate_premulRGBF(node->storage, out[0]->vec, in[0]->vec);
+}
+
+static bNodeType cmp_node_curve_vec= {
+       /* type code   */       CMP_NODE_CURVE_VEC,
+       /* name        */       "Vector Curves",
+       /* width+range */       200, 140, 320,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_curve_vec_in,
+       /* output sock */       cmp_node_curve_vec_out,
+       /* storage     */       "CurveMapping",
+       /* execfunc    */       node_composit_exec_curve_vec
+       
+};
+
+/* **************** CURVE RGB  ******************** */
+static bNodeSocketType cmp_node_curve_rgb_in[]= {
+       {       SOCK_RGBA, 1, "Image",  0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketType cmp_node_curve_rgb_out[]= {
+       {       SOCK_RGBA, 0, "Image",  0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_curves(bNode *node, float *out, float *in)
+{
+       curvemapping_evaluateRGBF(node->storage, out, in);
+       out[3]= in[3];
+}
+
+static void node_composit_exec_curve_rgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order input:  vec */
+       /* stack order output: vec */
+       
+       if(out[0]->hasoutput==0)
+               return;
+
+       /* input no image? then only color operation */
+       if(in[0]->data==NULL) {
+               curvemapping_evaluateRGBF(node->storage, out[0]->vec, in[0]->vec);
+       }
+       else {
+               /* make output size of input image */
+               CompBuf *cbuf= in[0]->data;
+               CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
+               
+               curvemapping_premultiply(node->storage, 0);
+               composit1_pixel_processor(node, stackbuf, in[0]->data, NULL, do_curves);
+               curvemapping_premultiply(node->storage, 1);
+               
+               out[0]->data= stackbuf;
+       }
+       
+}
+
+static bNodeType cmp_node_curve_rgb= {
+       /* type code   */       CMP_NODE_CURVE_RGB,
+       /* name        */       "RGB Curves",
+       /* width+range */       200, 140, 320,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_curve_rgb_in,
+       /* output sock */       cmp_node_curve_rgb_out,
+       /* storage     */       "CurveMapping",
+       /* execfunc    */       node_composit_exec_curve_rgb
+       
+};
+
+/* **************** VALUE ******************** */
+static bNodeSocketType cmp_node_value_out[]= {
+       {       SOCK_VALUE, 0, "Value",         0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_composit_exec_value(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       bNodeSocket *sock= node->outputs.first;
+       
+       out[0]->vec[0]= sock->ns.vec[0];
+}
+
+static bNodeType cmp_node_value= {
+       /* type code   */       CMP_NODE_VALUE,
+       /* name        */       "Value",
+       /* width+range */       80, 40, 120,
+       /* class+opts  */       NODE_CLASS_GENERATOR, NODE_OPTIONS,
+       /* input sock  */       NULL,
+       /* output sock */       cmp_node_value_out,
+       /* storage     */       "", 
+       /* execfunc    */       node_composit_exec_value
+       
+};
+
+/* **************** RGB ******************** */
+static bNodeSocketType cmp_node_rgb_out[]= {
+       {       SOCK_RGBA, 0, "RGBA",                   0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_composit_exec_rgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       bNodeSocket *sock= node->outputs.first;
+       
+       VECCOPY(out[0]->vec, sock->ns.vec);
+}
+
+static bNodeType cmp_node_rgb= {
+       /* type code   */       CMP_NODE_RGB,
+       /* name        */       "RGB",
+       /* width+range */       100, 60, 140,
+       /* class+opts  */       NODE_CLASS_GENERATOR, NODE_OPTIONS,
+       /* input sock  */       NULL,
+       /* output sock */       cmp_node_rgb_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_rgb
+       
+};
+
+/* **************** MIX RGB ******************** */
+static bNodeSocketType cmp_node_mix_rgb_in[]= {
+       {       SOCK_VALUE, 1, "Fac",                   0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_mix_rgb_out[]= {
+       {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float fac)
+{
+       float col[3];
+       
+       VECCOPY(col, in1);
+       ramp_blend(node->custom1, col, col+1, col+2, fac, in2);
+       VECCOPY(out, col);
+       out[3]= in1[3];
+}
+
+static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order in: fac, Image, Image */
+       /* stack order out: Image */
+       float fac= in[0]->vec[0];
+       
+       CLAMP(fac, 0.0f, 1.0f);
+       
+       /* input no image? then only color operation */
+       if(in[1]->data==NULL && in[2]->data==NULL) {
+               do_mix_rgb(node, out[0]->vec, in[1]->vec, in[2]->vec, fac);
+       }
+       else {
+               /* make output size of first available input image */
+               CompBuf *cbuf= in[1]->data?in[1]->data:in[2]->data;
+               CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
+               
+               composit3_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[0]->data, fac, do_mix_rgb);
+               
+               out[0]->data= stackbuf;
+       }
+}
+
+static bNodeType cmp_node_mix_rgb= {
+       /* type code   */       CMP_NODE_MIX_RGB,
+       /* name        */       "Mix",
+       /* width+range */       80, 40, 120,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_mix_rgb_in,
+       /* output sock */       cmp_node_mix_rgb_out,
+       /* storage     */       "", 
+       /* execfunc    */       node_composit_exec_mix_rgb
+       
+};
+
+/* **************** FILTER  ******************** */
+static bNodeSocketType cmp_node_filter_in[]= {
+       {       SOCK_VALUE, 1, "Fac",                   1.0f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_filter_out[]= {
+       {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac)
+{
+       float *row1, *row2, *row3;
+       float *fp, f1, f2, mfac= 1.0f-fac;
+       int rowlen, x, y, c;
+       
+       rowlen= in->x;
+       
+       if(in->type==CB_RGBA) {
+               
+               for(y=2; y<in->y; y++) {
+                       /* setup rows */
+                       row1= in->rect + 4*(y-2)*rowlen;
+                       row2= row1 + 4*rowlen;
+                       row3= row2 + 4*rowlen;
+                       fp= out->rect + 4*(y-1)*rowlen + 4;
+                       
+                       for(x=2; x<rowlen; x++) {
+                               for(c=0; c<3; c++) {
+                                       f1= filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8];
+                                       f2= filter[0]*row1[0] + filter[3]*row1[4] + filter[6]*row1[8] + filter[1]*row2[0] + filter[4]*row2[4] + filter[7]*row2[8] + filter[2]*row3[0] + filter[5]*row3[4] + filter[8]*row3[8];
+                                       fp[0]= mfac*row2[4] + fac*sqrt(f1*f1 + f2*f2);
+                                       fp++; row1++; row2++; row3++;
+                               }
+                               fp[0]= row2[4];
+                               /* no alpha... will clear it completely */
+                               fp++; row1++; row2++; row3++;
+                       }
+               }
+       }       
+}
+
+static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac)
+{
+       float *row1, *row2, *row3;
+       float *fp, mfac= 1.0f-fac;
+       int rowlen, x, y, c;
+       
+       rowlen= in->x;
+       
+       if(in->type==CB_RGBA) {
+               
+               for(y=2; y<in->y; y++) {
+                       /* setup rows */
+                       row1= in->rect + 4*(y-2)*rowlen;
+                       row2= row1 + 4*rowlen;
+                       row3= row2 + 4*rowlen;
+                       fp= out->rect + 4*(y-1)*rowlen + 4;
+                       
+                       for(x=2; x<rowlen; x++) {
+                               for(c=0; c<4; c++) {
+                                       fp[0]= mfac*row2[4] + fac*(filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]);
+                                       fp++; row1++; row2++; row3++;
+                               }
+                       }
+               }
+       }       
+}
+
+static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
+       float sharp[9]= {-1,-1,-1,-1,9,-1,-1,-1,-1};
+       float laplace[9]= {1/8.0f, -1/8.0f, 1/8.0f, -1/8.0f, 1.0f, -1/8.0f, 1/8.0f, -1/8.0f, 1/8.0f};
+       float sobel[9]= {1,2,1,0,0,0,-1,-2,-1};
+       float prewitt[9]= {1,1,1,0,0,0,-1,-1,-1};
+       float kirsch[9]= {5,5,5,-3,-3,-3,-2,-2,-2};
+       float shadow[9]= {1,2,1,0,1,0,-1,-2,-1};
+       
+       /* stack order in: Image */
+       /* stack order out: Image */
+       
+       if(in[1]->data) {
+               /* make output size of first available input image */
+               CompBuf *cbuf= in[1]->data;
+               CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
+               
+               switch(node->custom1) {
+                       case CMP_FILT_SOFT:
+                               do_filter3(stackbuf, cbuf, soft, in[0]->vec[0]);
+                               break;
+                       case CMP_FILT_SHARP:
+                               do_filter3(stackbuf, cbuf, sharp, in[0]->vec[0]);
+                               break;
+                       case CMP_FILT_LAPLACE:
+                               do_filter3(stackbuf, cbuf, laplace, in[0]->vec[0]);
+                               break;
+                       case CMP_FILT_SOBEL:
+                               do_filter_edge(stackbuf, cbuf, sobel, in[0]->vec[0]);
+                               break;
+                       case CMP_FILT_PREWITT:
+                               do_filter_edge(stackbuf, cbuf, prewitt, in[0]->vec[0]);
+                               break;
+                       case CMP_FILT_KIRSCH:
+                               do_filter_edge(stackbuf, cbuf, kirsch, in[0]->vec[0]);
+                               break;
+                       case CMP_FILT_SHADOW:
+                               do_filter3(stackbuf, cbuf, shadow, in[0]->vec[0]);
+                               break;
+               }
+                       
+               out[0]->data= stackbuf;
+       }
+}
+
+static bNodeType cmp_node_filter= {
+       /* type code   */       CMP_NODE_FILTER,
+       /* name        */       "Filter",
+       /* width+range */       80, 40, 120,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_filter_in,
+       /* output sock */       cmp_node_filter_out,
+       /* storage     */       "", 
+       /* execfunc    */       node_composit_exec_filter
+       
+};
+
+
+/* **************** VALTORGB ******************** */
+static bNodeSocketType cmp_node_valtorgb_in[]= {
+       {       SOCK_VALUE, 1, "Fac",                   0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_valtorgb_out[]= {
+       {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 0, "Alpha",                 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_colorband_composit(bNode *node, float *out, float *in)
+{
+       do_colorband(node->storage, in[0], out);
+}
+
+static void node_composit_exec_valtorgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order in: fac */
+       /* stack order out: col, alpha */
+       
+       if(node->storage) {
+               /* input no image? then only color operation */
+               if(in[0]->data==NULL) {
+                       do_colorband(node->storage, in[0]->vec[0], out[0]->vec);
+               }
+               else {
+                       /* make output size of input image */
+                       CompBuf *cbuf= in[0]->data;
+                       CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
+                       
+                       composit1_pixel_processor(node, stackbuf, in[0]->data, NULL, do_colorband_composit);
+                       
+                       out[0]->data= stackbuf;
+                       
+                       if(out[1]->hasoutput)
+                               out[1]->data= alphabuf_from_rgbabuf(stackbuf);
+
+               }
+       }
+}
+
+static bNodeType cmp_node_valtorgb= {
+       /* type code   */       CMP_NODE_VALTORGB,
+       /* name        */       "ColorRamp",
+       /* width+range */       240, 200, 300,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_valtorgb_in,
+       /* output sock */       cmp_node_valtorgb_out,
+       /* storage     */       "ColorBand",
+       /* execfunc    */       node_composit_exec_valtorgb
+       
+};
+
+
+/* **************** RGBTOBW ******************** */
+static bNodeSocketType cmp_node_rgbtobw_in[]= {
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_rgbtobw_out[]= {
+       {       SOCK_VALUE, 0, "Val",                   0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_rgbtobw(bNode *node, float *out, float *in)
+{
+       out[0]= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f;
+}
+
+static void node_composit_exec_rgbtobw(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order out: bw */
+       /* stack order in: col */
+       
+       /* input no image? then only color operation */
+       if(in[0]->data==NULL) {
+               out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f;
+       }
+       else {
+               /* make output size of input image */
+               CompBuf *cbuf= in[0]->data;
+               CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); // allocs
+               
+               composit1_pixel_processor(node, stackbuf, in[0]->data, NULL, do_rgbtobw);
+               
+               out[0]->data= stackbuf;
+       }
+}
+
+static bNodeType cmp_node_rgbtobw= {
+       /* type code   */       CMP_NODE_RGBTOBW,
+       /* name        */       "RGB to BW",
+       /* width+range */       80, 40, 120,
+       /* class+opts  */       NODE_CLASS_OPERATOR, 0,
+       /* input sock  */       cmp_node_rgbtobw_in,
+       /* output sock */       cmp_node_rgbtobw_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_rgbtobw
+       
+};
+
+/* **************** ALPHAOVER ******************** */
+static bNodeSocketType cmp_node_alphaover_in[]= {
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_alphaover_out[]= {
+       {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_alphaover(bNode *node, float *out, float *src, float *dest)
+{
+       float mul= 1.0f - dest[3];
+       
+       if(mul<=0.0f) {
+               QUATCOPY(out, dest);
+       }
+       else {
+               out[0]= (mul*src[0]) + dest[0];
+               out[1]= (mul*src[1]) + dest[1];
+               out[2]= (mul*src[2]) + dest[2];
+               out[3]= (mul*src[3]) + dest[3];
+       }       
+}
+
+static void node_composit_exec_alphaover(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order in: col col */
+       /* stack order out: col */
+       
+       /* input no image? then only color operation */
+       if(in[0]->data==NULL) {
+               do_alphaover(node, out[0]->vec, in[0]->vec, in[1]->vec);
+       }
+       else {
+               /* make output size of input image */
+               CompBuf *cbuf= in[0]->data;
+               CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
+               
+               composit2_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_alphaover);
+               
+               out[0]->data= stackbuf;
+       }
+}
+
+static bNodeType cmp_node_alphaover= {
+       /* type code   */       CMP_NODE_ALPHAOVER,
+       /* name        */       "AlphaOver",
+       /* width+range */       80, 40, 120,
+       /* class+opts  */       NODE_CLASS_OPERATOR, 0,
+       /* input sock  */       cmp_node_alphaover_in,
+       /* output sock */       cmp_node_alphaover_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_alphaover
+       
+};
+
+/* **************** GAUSS BLUR ******************** */
+static bNodeSocketType cmp_node_blur_in[]= {
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_blur_out[]= {
+       {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+
+static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       CompBuf *new, *work, *img= in[0]->data;
+       register float sum, val;
+       float rval, gval, bval, aval;
+       float *gausstab, *v;
+       int r, n, m;
+       int x, y;
+       int i;
+       int step, bigstep;
+       float *src, *dest;
+
+       
+       if(img==NULL || out[0]->hasoutput==0)
+               return;
+       
+       /* make output size of input image */
+       new= alloc_compbuf(img->x, img->y, CB_RGBA, 1); // allocs
+       out[0]->data= new;
+       
+       /* prepare for gauss tab */
+       r = (1.5 * node->custom1 + 1.5);
+       n = 2 * r + 1;
+       
+       /* ugly : */
+       if ((img->x <= n) || (img->y <= n)) {
+               printf("gauss filter too large/n");
+               return;
+       }
+       
+       gausstab = (float *) MEM_mallocN(n * sizeof(float), "gauss");
+       
+       sum = 0.0f;
+       v = gausstab;
+       for (x = -r; x <= r; x++) {
+               val = exp(-4*(float ) (x*x)/ (float) (r*r));
+               sum += val;
+               *v++ = val;
+       }
+       
+       i = n;
+       v = gausstab;
+       while (i--) {
+               *v++ /= sum;
+       }
+       
+       /* helper image */
+       work= alloc_compbuf(img->x, img->y, CB_RGBA, 1); // allocs
+       
+       /* horizontal */
+       step = (n - 1);
+       
+       for (y = 0; y < img->y; y++) {
+               src = img->rect + 4*(y * img->x);
+               dest = work->rect + 4*(y * img->x);
+               
+               for (x = r; x > 0 ; x--) {
+                       m = n - x;
+                       gval = rval= bval= aval= 0.0f;
+                       sum = 0.0;
+                       v = gausstab + x;
+                       for (i = 0; i < m; i++) {
+                               val = *v++;
+                               sum += val;
+                               rval += val * (*src++);
+                               gval += val * (*src++);
+                               bval += val * (*src++);
+                               aval += val * (*src++);
+                       }
+                       *dest++ = rval / sum;
+                       *dest++ = gval / sum;
+                       *dest++ = bval / sum;
+                       *dest++ = aval / sum;
+                       
+                       src -= 4*m;
+               }
+               
+               for (x = 0; x <= (img->x - n); x++) {
+                       gval = rval= bval= aval= 0.0f;
+                       v = gausstab;
+                       
+                       for (i = 0; i < n; i++) {
+                               val = *v++;
+                               rval += val * (*src++);
+                               gval += val * (*src++);
+                               bval += val * (*src++);
+                               aval += val * (*src++);
+                       }
+                       *dest++ = rval;
+                       *dest++ = gval;
+                       *dest++ = bval;
+                       *dest++ = aval;
+                       src -= 4*step;
+               }       
+               
+               for (x = 1; x <= r ; x++) {
+                       m = n - x;
+                       gval = rval= bval= aval= 0.0f;
+                       sum = 0.0;
+                       v = gausstab;
+                       for (i = 0; i < m; i++) {
+                               val = *v++;
+                               sum += val;
+                               rval += val * (*src++);
+                               gval += val * (*src++);
+                               bval += val * (*src++);
+                               aval += val * (*src++);
+                       }
+                       *dest++ = rval / sum;
+                       *dest++ = gval / sum;
+                       *dest++ = bval / sum;
+                       *dest++ = aval / sum;
+                       src -= 4*(m - 1);
+               }
+       }
+       
+       /* vertical */
+       MEM_freeN(gausstab);
+       
+       /* prepare for gauss tab */
+       r = (1.5 * node->custom2 + 1.5);
+       n = 2 * r + 1;
+       
+       /* ugly : */
+       if ((img->x <= n) || (img->y <= n)) {
+               printf("gauss filter too large/n");
+               return;
+       }
+       
+       gausstab = (float *) MEM_mallocN(n * sizeof(float), "gauss");
+       
+       sum = 0.0f;
+       v = gausstab;
+       for (x = -r; x <= r; x++) {
+               val = exp(-4*(float ) (x*x)/ (float) (r*r));
+               sum += val;
+               *v++ = val;
+       }
+       
+       i = n;
+       v = gausstab;
+       while (i--) {
+               *v++ /= sum;
+       }
+       
+       step = img->x;
+       bigstep = (n - 1) * step;
+       for (x = 0; x < step  ; x++) {
+               dest = new->rect + 4*x;
+               src = work->rect + 4*x;
+               
+               for (y = r; y > 0; y--) {
+                       m = n - y;
+                       gval = rval= bval= aval= 0.0f;
+                       sum = 0.0;
+                       v = gausstab + y;
+                       for (i = 0; i < m; i++) {
+                               val = *v++;
+                               sum += val;
+                               rval += val * src[0];
+                               gval += val * src[1];
+                               bval += val * src[2];
+                               aval += val * src[3];
+                               src += 4 * step;
+                       }
+                       dest[0] = rval / sum;
+                       dest[1] = gval / sum;
+                       dest[2] = bval / sum;
+                       dest[3] = aval / sum;
+                       src -= 4 * m * step;
+                       dest+= 4 * step;
+               }
+               for (y = 0; y <= (img->y - n); y++) {
+                       gval = rval= bval= aval= 0.0f;
+                       v = gausstab;
+                       for (i = 0; i < n; i++) {
+                               val = *v++;
+                               rval += val * src[0];
+                               gval += val * src[1];
+                               bval += val * src[2];
+                               aval += val * src[3];
+                               src += 4 * step;
+                       }
+                       dest[0] = rval;
+                       dest[1] = gval;
+                       dest[2] = bval;
+                       dest[3] = aval;
+                       dest += 4 * step;
+                       src -= 4 * bigstep;
+               }
+               for (y = 1; y <= r ; y++) {
+                       m = n - y;
+                       gval = rval= bval= aval= 0.0f;
+                       sum = 0.0;
+                       v = gausstab;
+                       for (i = 0; i < m; i++) {
+                               val = *v++;
+                               sum += val;
+                               rval += val * src[0];
+                               gval += val * src[1];
+                               bval += val * src[2];
+                               aval += val * src[3];
+                               src += 4 * step;
+                       }
+                       dest[0] = rval / sum;
+                       dest[1] = gval / sum;
+                       dest[2] = bval / sum;
+                       dest[3] = aval / sum;
+                       dest += 4* step;
+                       src -= 4 * (m - 1) * step;
+               }
+       }
+
+       free_compbuf(work);
+       MEM_freeN(gausstab);
+}
+
+static bNodeType cmp_node_blur= {
+       /* type code   */       CMP_NODE_BLUR,
+       /* name        */       "Blur",
+       /* width+range */       120, 80, 200,
+       /* class+opts  */       NODE_CLASS_OPERATOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_blur_in,
+       /* output sock */       cmp_node_blur_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_blur
+       
+};
+
+
+/* ****************** types array for all shaders ****************** */
+
+bNodeType *node_all_composit[]= {
+       &node_group_typeinfo,
+       &cmp_node_output,
+       &cmp_node_value,
+       &cmp_node_rgb,
+       &cmp_node_mix_rgb,
+       &cmp_node_filter,
+       &cmp_node_valtorgb,
+       &cmp_node_rgbtobw,
+       &cmp_node_normal,
+       &cmp_node_curve_vec,
+       &cmp_node_curve_rgb,
+       &cmp_node_image,
+       &cmp_node_rresult,
+       &cmp_node_alphaover,
+       &cmp_node_blur,
+       NULL
+};
+
+/* ******************* execute and parse ************ */
+
+void ntreeCompositExecTree(bNodeTree *ntree)
+{
+       
+       ntreeInitPreview(ntree, 0, 0);
+       ntreeBeginExecTree(ntree);
+
+       /* allocate composit data */
+       
+       ntreeExecTree(ntree, NULL, 0);  /* threads */
+       
+       ntreeEndExecTree(ntree);
+}
+
index 944db32ccc10ffd620232545abd9487051505ef2..4e65b36588c532bf20387768685d00f3c39a7b56 100644 (file)
@@ -38,6 +38,7 @@
 #include "BKE_blender.h"
 #include "BKE_colortools.h"
 #include "BKE_node.h"
+#include "BKE_material.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
@@ -46,7 +47,7 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "render.h"            /* <- shadeinput/output */
+#include "RE_shader_ext.h"             /* <- ShadeInput Shaderesult TexResult */
 
 
 /* ********* exec data struct, remains internal *********** */
@@ -727,11 +728,11 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
        scd.shi= shi;
        scd.shr= shr;
        
-       ntreeExecTree(ntree, &scd, shi->ys & 1);        /* threads */
+       ntreeExecTree(ntree, &scd, shi->thread);        /* threads */
 }
 
 /* go over all used Geometry and Texture nodes, and return a texco flag */
-int ntreeShaderGetTexco(bNodeTree *ntree)
+int ntreeShaderGetTexco(bNodeTree *ntree, int osa)
 {
        bNode *node;
        bNodeSocket *sock;
@@ -741,8 +742,7 @@ int ntreeShaderGetTexco(bNodeTree *ntree)
        
        for(node= ntree->nodes.first; node; node= node->next) {
                if(node->type==SH_NODE_TEXTURE) {
-                       /* this r.osa is sorta weak... */
-                       if(R.osa && node->id) {
+                       if(osa && node->id) {
                                Tex *tex= (Tex *)node->id;
                                if ELEM3(tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) texco |= TEXCO_OSA;
                        }
index d60236d226cb9cbae93a796ba0d2ad4b1de2a42d..0b52c92f50e7ec9448322d1127507b5c4cd3ff21 100644 (file)
@@ -995,10 +995,10 @@ void make_local_object(Object *ob)
 float bluroffs= 0.0;
 int no_speed_curve= 0;
 
-void set_mblur_offs(int blur)
+/* ugly call from render */
+void set_mblur_offs(float blur)
 {
-       bluroffs= R.r.blurfac*((float)blur);
-       bluroffs/= (float)R.r.osa;
+       bluroffs= blur;
 }
        
 void disable_speed_curve(int val)
@@ -1012,9 +1012,9 @@ float bsystem_time(Object *ob, Object *par, float cfra, float ofs)
        /* returns float ( see frame_to_float in ipo.c) */
 
        /* 2nd field */
-       if(R.flag & R_SEC_FIELD) {
-               if(R.r.mode & R_FIELDSTILL); else cfra+= .5;
-       }
+//     if(R.flag & R_SEC_FIELD) {
+//             if(R.r.mode & R_FIELDSTILL); else cfra+= .5;
+//     }
 
        cfra+= bluroffs;
 
index f0058ee6ad047e680a6d0b838bedd24b337793c2..cb47c43da06ed76f34e9e084150f3e5ea01afb24 100644 (file)
 #include "DNA_sound_types.h"
 #include "DNA_vfont_types.h"
 #include "DNA_packedFile_types.h"
-
+#include "DNA_scene_types.h"
 
 #include "BLI_blenlib.h"
 
 #include "BKE_utildefines.h"
-#include "BKE_bad_level_calls.h"
-
 #include "BKE_global.h"
 #include "BKE_main.h"
-
 #include "BKE_screen.h"
-
 #include "BKE_sound.h"
-//#include "sound.h"
-
 #include "BKE_image.h"
 #include "BKE_font.h"
 #include "BKE_packedFile.h"
+#include "BKE_bad_level_calls.h" /* <- waitcursor */
 
 int seekPackedFile(PackedFile * pf, int offset, int whence)
 {
@@ -309,7 +304,7 @@ int writePackedFile(char * filename, PackedFile *pf)
        }
        
        // make sure the path to the file exists...
-       RE_make_existing_file(name);
+       BLI_make_existing_file(name);
        
        file = open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
        if (file >= 0) {
index df9e626abbf9b7d09adc206eb4b841b6f40c5df6..546a22c361bba84177b0ebce2eed37bfb3fbdd0c 100644 (file)
@@ -70,6 +70,7 @@
 #include "BKE_key.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_node.h"
 #include "BKE_object.h"
 #include "BKE_scene.h"
 #include "BKE_world.h"
@@ -153,6 +154,11 @@ void free_scene(Scene *sce)
                free_forest(sce->theDag);
                MEM_freeN(sce->theDag);
        }
+       
+       if(sce->nodetree) {
+               ntreeFreeTree(sce->nodetree);
+               MEM_freeN(sce->nodetree);
+       }
 }
 
 Scene *add_scene(char *name)
@@ -172,8 +178,8 @@ Scene *add_scene(char *name)
        sce->r.ysch= 256;
        sce->r.xasp= 1;
        sce->r.yasp= 1;
-       sce->r.xparts= 1;
-       sce->r.yparts= 1;
+       sce->r.xparts= 4;
+       sce->r.yparts= 4;
        sce->r.size= 100;
        sce->r.planes= 24;
        sce->r.quality= 90;
index ea0134470f1a24d80c94d2786216ea8904c890fa..2633bbd2779fc1455bd276c2164a909ae625dfe1 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "BLI_blenlib.h"
 
+#include "DNA_scene_types.h"
 #include "DNA_text_types.h"
 
 #include "BKE_bad_level_calls.h"
index 902b3a5edfebb38ebe385bb9ffef62c04ab8ecd4..aa36c0a50831a82bdfdad9eaee83b321e847d152 100644 (file)
@@ -57,6 +57,7 @@
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_image_types.h"
+#include "DNA_world_types.h"
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
@@ -158,6 +159,10 @@ void open_plugin_tex(PluginTex *pit)
 
 /* ------------------------------------------------------------------------- */
 
+/* very badlevel define to bypass linking with BIF_interface.h */
+#define INT    96
+#define FLO    128
+
 PluginTex *add_plugin_tex(char *str)
 {
        PluginTex *pit;
@@ -381,7 +386,7 @@ void free_texture(Tex *tex)
 {
        free_plugin_tex(tex->plugin);
        if(tex->coba) MEM_freeN(tex->coba);
-       if(tex->env) RE_free_envmap(tex->env);
+       if(tex->env) BKE_free_envmap(tex->env);
        BKE_icon_delete((struct ID*)tex);
        tex->id.icon_id = 0;
 }
@@ -527,7 +532,7 @@ Tex *copy_texture(Tex *tex)
        }
        
        if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
-       if(texn->env) texn->env= RE_copy_envmap(texn->env);
+       if(texn->env) texn->env= BKE_copy_envmap(texn->env);
        
        return texn;
 }
@@ -714,3 +719,69 @@ Tex *give_current_texture(Object *ob, int act)
        
        return tex;
 }
+
+
+/* ------------------------------------------------------------------------- */
+
+EnvMap *BKE_add_envmap(void)
+{
+       EnvMap *env;
+       
+       env= MEM_callocN(sizeof(EnvMap), "envmap");
+       env->type= ENV_CUBE;
+       env->stype= ENV_STATIC;
+       env->clipsta= 0.1;
+       env->clipend= 100.0;
+       env->cuberes= 100;
+       
+       return env;
+} 
+
+/* ------------------------------------------------------------------------- */
+
+EnvMap *BKE_copy_envmap(EnvMap *env)
+{
+       EnvMap *envn;
+       int a;
+       
+       envn= MEM_dupallocN(env);
+       envn->ok= 0;
+       for(a=0; a<6; a++) envn->cube[a]= 0;
+       if(envn->ima) id_us_plus((ID *)envn->ima);
+       
+       return envn;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void BKE_free_envmapdata(EnvMap *env)
+{
+       Image *ima;
+       unsigned int a, part;
+       
+       for(part=0; part<6; part++) {
+               ima= env->cube[part];
+               if(ima) {
+                       if(ima->ibuf) IMB_freeImBuf(ima->ibuf);
+                       
+                       for(a=0; a<BLI_ARRAY_NELEMS(ima->mipmap); a++) {
+                               if(ima->mipmap[a]) IMB_freeImBuf(ima->mipmap[a]);
+                       }
+                       MEM_freeN(ima);
+                       env->cube[part]= 0;
+               }
+       }
+       env->ok= 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void BKE_free_envmap(EnvMap *env)
+{
+       
+       BKE_free_envmapdata(env);
+       MEM_freeN(env);
+       
+}
+
+/* ------------------------------------------------------------------------- */
index 1f71b01d33a1a386154aba2abcd60279272cd4ca..3ff980110e7bedfa8eda6f538a9ccc86fdb1635a 100644 (file)
@@ -178,38 +178,3 @@ void make_local_world(World *wrld)
                }
        }
 }
-
-
-void init_render_world()
-{
-       int a;
-       char *cp;
-       
-       if(G.scene->world) {
-               R.wrld= *(G.scene->world);
-               
-               cp= (char *)&R.wrld.fastcol;
-               
-               cp[0]= 255.0*R.wrld.horr;
-               cp[1]= 255.0*R.wrld.horg;
-               cp[2]= 255.0*R.wrld.horb;
-               cp[3]= 1;
-               
-               VECCOPY(R.grvec, R.viewmat[2]);
-               Normalise(R.grvec);
-               Mat3CpyMat4(R.imat, R.viewinv);
-               
-               for(a=0; a<MAX_MTEX; a++) 
-                       if(R.wrld.mtex[a] && R.wrld.mtex[a]->tex) R.wrld.skytype |= WO_SKYTEX;
-               
-               while(R.wrld.aosamp*R.wrld.aosamp < R.osa) R.wrld.aosamp++;
-       }
-       else {
-               memset(&R.wrld, 0, sizeof(World));
-               R.wrld.exp= 0.0;
-               R.wrld.range= 1.0;
-       }
-
-       R.wrld.linfac= 1.0 + pow((2.0*R.wrld.exp + 0.5), -10);
-       R.wrld.logfac= log( (R.wrld.linfac-1.0)/R.wrld.linfac )/R.wrld.range;
-}
index 0d94215816a47d0fea7e6b180b916f8bc65b564f..d754a694d5d0127b0434b6215a6f041fee661710 100644 (file)
@@ -1,5 +1,6 @@
 /**
  * Functions for writing avi-format files.
+ * Added interface for generic movie support (ton)
  *
  * $Id$
  *
 #include <string.h>
 
 #include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+
 #include "BLI_blenlib.h"
 
+#include "BKE_global.h"
+#include "BKE_writeavi.h"
+
 #include "AVI_avi.h"
 
-#include "BKE_bad_level_calls.h"
-#include "BKE_global.h"
 
-/* RPW 11-21-2002 */
-#include "DNA_scene_types.h"
-/* RPW - End */
+/* ********************** general blender movie support ***************************** */
+
+#ifdef WITH_QUICKTIME
+#include "quicktime_export.h"
+#endif
+
+bMovieHandle *BKE_get_movie_handle(int imtype)
+{
+       static bMovieHandle mh;
+       
+       /* set the default handle, as builtin */
+       mh.start_movie= start_avi;
+       mh.append_movie= append_avi;
+       mh.end_movie= end_avi;
+       
+       /* do the platform specific handles */
+#ifdef __sgi
+       if (imtype == R_MOVIE) {
+               
+       }
+#endif
+#if defined(_WIN32) && !defined(FREE_WINDOWS)
+       if (imtype == R_AVICODEC) {
+               
+       }
+#endif
+#ifdef WITH_QUICKTIME
+       if (imtype == R_QUICKTIME) {
+               mh.start_movie= start_qt;
+               mh.append_movie= append_qt;
+               mh.end_movie= end_qt;
+       }
+#endif
+       
+       return &mh;
+}
+
+/* ****************************************************************** */
 
-#include "BKE_writeavi.h"
 
 static AviMovie *avi=NULL;
 static int sframe;
 
-void makeavistring (char *string) 
+void makeavistring (RenderData *rd, char *string) 
 {
        char txt[64];
 
        if (string==0) return;
 
-       strcpy(string, G.scene->r.pic);
-       BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
+       strcpy(string, rd->pic);
+       BLI_convertstringcode(string, G.sce, rd->cfra);
 
-       RE_make_existing_file(string);
+       BLI_make_existing_file(string);
 
        if (BLI_strcasecmp(string + strlen(string) - 4, ".avi")) {
-               sprintf(txt, "%04d_%04d.avi", (G.scene->r.sfra) , (G.scene->r.efra) );
+               sprintf(txt, "%04d_%04d.avi", (rd->sfra) , (rd->efra) );
                strcat(string, txt);
        }
 }
 
-void start_avi(void)
+void start_avi(RenderData *rd, int rectx, int recty)
 {
        int x, y;
        char name[256];
        AviFormat format;
        int quality, framerate;
        
-       makeavistring(name);
+       makeavistring(rd, name);
 
-       sframe = (G.scene->r.sfra);
-       x = R.rectx;
-       y = R.recty;
+       sframe = (rd->sfra);
+       x = rectx;
+       y = recty;
 
-       quality= R.r.quality;
-       framerate= R.r.frs_sec;
+       quality= rd->quality;
+       framerate= rd->frs_sec;
        
        avi = MEM_mallocN (sizeof(AviMovie), "avimovie");
 
        /* RPW 11-21-2002 
-        if (R.r.imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB;
+        if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB;
        */
-       if (R.r.imtype != R_AVIJPEG ) format = AVI_FORMAT_AVI_RGB;
+       if (rd->imtype != R_AVIJPEG ) format = AVI_FORMAT_AVI_RGB;
        else format = AVI_FORMAT_MJPEG;
 
        if (AVI_open_compress (name, avi, 1, format) != AVI_ERROR_NONE) {
-               error("open movie");
+               printf("cannot open or start AVI movie file");
                MEM_freeN (avi);
                avi = NULL;
                return;
@@ -107,13 +146,13 @@ void start_avi(void)
 
        avi->interlace= 0;
        avi->odd_fields= 0;
-/*     avi->interlace= R.r.mode & R_FIELDS; */
-/*     avi->odd_fields= (R.r.mode & R_ODDFIELD)?1:0; */
+/*     avi->interlace= rd->mode & R_FIELDS; */
+/*     avi->odd_fields= (rd->mode & R_ODDFIELD)?1:0; */
        
        printf("Created avi: %s\n", name);
 }
 
-void append_avi(int frame)
+void append_avi(int frame, int *pixels, int rectx, int recty)
 {
        unsigned int *rt1, *rt2, *rectot;
        int x, y;
@@ -125,15 +164,15 @@ void append_avi(int frame)
        }
 
        /* note that libavi free's the buffer... stupid interface - zr */
-       rectot= MEM_mallocN(R.rectx*R.recty*sizeof(int), "rectot");
+       rectot= MEM_mallocN(rectx*recty*sizeof(int), "rectot");
        rt1= rectot;
-       rt2= R.rectot + (R.recty-1)*R.rectx;
+       rt2= pixels + (recty-1)*rectx;
        /* flip y and convert to abgr */
-       for (y=0; y < R.recty; y++, rt1+= R.rectx, rt2-= R.rectx) {
-               memcpy (rt1, rt2, R.rectx*sizeof(int));
+       for (y=0; y < recty; y++, rt1+= rectx, rt2-= rectx) {
+               memcpy (rt1, rt2, rectx*sizeof(int));
                
                cp= (char *)rt1;
-               for(x= R.rectx; x>0; x--) {
+               for(x= rectx; x>0; x--) {
                        rt= cp[0];
                        cp[0]= cp[3];
                        cp[3]= rt;
@@ -144,8 +183,8 @@ void append_avi(int frame)
                }
        }
        
-       AVI_write_frame (avi, (frame-sframe), AVI_FORMAT_RGB32, rectot, R.rectx*R.recty*4);
-       printf ("added frame %3d (frame %3d in avi): ", frame, frame-sframe);
+       AVI_write_frame (avi, (frame-sframe), AVI_FORMAT_RGB32, rectot, rectx*recty*4);
+//     printf ("added frame %3d (frame %3d in avi): ", frame, frame-sframe);
 }
 
 void end_avi(void)
index 7a5e162a4b8fa1377bcd7d457c96aa980470b12a..c920d7127ae9b1f6cda3d1ab602a24a3537a5cdd 100644 (file)
@@ -93,6 +93,7 @@ extern "C" {
 char *BLI_gethome(void);
 void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file);
 void BLI_make_exist(char *dir);
+void BLI_make_existing_file(char *name);
 void BLI_split_dirfile(char *string, char *dir, char *file);
 int BLI_testextensie(char *str, char *ext);
 void addlisttolist(ListBase *list1, ListBase *list2);
@@ -277,13 +278,15 @@ char *BLI_last_slash(char *string);
  *
  * @return True if @a rect is empty.
  */
-int BLI_rcti_is_empty(struct rcti * rect);
+int  BLI_rcti_is_empty(struct rcti * rect);
 void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
+void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
+void BLI_translate_rctf(struct rctf *rect, float x, float y);
+void BLI_translate_rcti(struct rcti *rect, int x, int y);
 int  BLI_in_rcti(struct rcti * rect, int x, int y);
 int  BLI_in_rctf(struct rctf *rect, float x, float y);
 int  BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest);
-/* why oh why doesn't this work? */
-//void BLI_union_rctf(struct rctf *rct1, struct rctf *rct2);
+int  BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest);
 void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb);
 
 /* scanfill.c: used in displist only... */
@@ -336,6 +339,7 @@ void BLI_setInterruptCallBack(int (*f)(void));
 
 int BLI_strcasecmp(const char *s1, const char *s2);
 int BLI_strncasecmp(const char *s1, const char *s2, int n);
+void BLI_timestr(double time, char *str);
 
 #define PRNTSUB(type,arg)                      printf(#arg ": %" #type " ", arg)
 
similarity index 64%
rename from source/blender/render/intern/include/outerRenderLoop.h
rename to source/blender/blenlib/BLI_jitter.h
index 1c0faf666ae1eaba2f49b4a614d6f2a90620d4d5..1cd4880d0b73ba4e60a9c3c4fcf5201f80f8692d 100644 (file)
@@ -1,17 +1,14 @@
 /*
- * outerRenderLoop.h
+ * jitter.h
  *
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef OUTERRENDERLOOP_H
-#define OUTERRENDERLOOP_H
+#ifndef BLI_JITTER_H
+#define BLI_JITTER_H 
 
-/**
- * Outer loop for rendering a single picture.
- */
-void unifiedRenderingLoop(void);
+extern void       BLI_initjit(float *jitarr, int num);
+extern void    BLI_jitterate1(float *jit1, float *jit2, int num, float rad1);
+extern void    BLI_jitterate2(float *jit1, float *jit2, int num, float rad2);
 
 #endif
 
similarity index 80%
rename from source/blender/render/intern/source/jitter.c
rename to source/blender/blenlib/intern/jitter.c
index 98bb1543068853932f60739efd36df6e1e833888..fd65876580254708a059cea0ed5dc618c6ec78c4 100644 (file)
@@ -3,15 +3,12 @@
  *
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version. 
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,7 +26,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 #include <math.h>
 
 #include "BLI_arithb.h"
 #include "BLI_rand.h"
-#include "render.h"
-#include "jitter.h"
+#include "BLI_jitter.h"
 
 
-float jit[64][2];
-
-void init_render_jit(int nr);
-
-
-void RE_jitterate1(float *jit1, float *jit2, int num, float rad1)
+void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1)
 {
        int i , j , k;
        float vecx, vecy, dvecx, dvecy, x, y, len;
@@ -106,7 +97,7 @@ void RE_jitterate1(float *jit1, float *jit2, int num, float rad1)
        memcpy(jit1,jit2,2 * num * sizeof(float));
 }
 
-void RE_jitterate2(float *jit1, float *jit2, int num, float rad2)
+void BLI_jitterate2(float *jit1, float *jit2, int num, float rad2)
 {
        int i, j;
        float vecx, vecy, dvecx, dvecy, x, y;
@@ -146,7 +137,7 @@ void RE_jitterate2(float *jit1, float *jit2, int num, float rad2)
 }
 
 
-void initjit(float *jitarr, int num)
+void BLI_initjit(float *jitarr, int num)
 {
        float *jit2, x, rad1, rad2, rad3;
        int i;
@@ -168,9 +159,9 @@ void initjit(float *jitarr, int num)
        }
 
        for (i=0 ; i<24 ; i++) {
-               RE_jitterate1(jitarr, jit2, num, rad1);
-               RE_jitterate1(jitarr, jit2, num, rad1);
-               RE_jitterate2(jitarr, jit2, num, rad2);
+               BLI_jitterate1(jitarr, jit2, num, rad1);
+               BLI_jitterate1(jitarr, jit2, num, rad1);
+               BLI_jitterate2(jitarr, jit2, num, rad2);
        }
 
        MEM_freeN(jit2);
@@ -183,16 +174,5 @@ void initjit(float *jitarr, int num)
        
 }
 
-void init_render_jit(int nr)
-{
-       static int lastjit= 0;
-       
-       if(lastjit==nr) return;
-
-       memset(jit, 0, 64*2*4);
-       initjit(jit[0], nr);
-
-       lastjit= nr;
-}
 
 /* eof */
index 1b19a6b769d756c79ad9e67185ae77954de0fc58..60d969225440819b2628336883098abcc2b4edc6 100644 (file)
@@ -87,6 +87,28 @@ void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax)
        rect->ymin= ymin;
        rect->ymax= ymax;
 }
+void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax)
+{
+       rect->xmin= xmin;
+       rect->xmax= xmax;
+       rect->ymin= ymin;
+       rect->ymax= ymax;
+}
+
+void BLI_translate_rcti(rcti *rect, int x, int y)
+{
+       rect->xmin += x;
+       rect->ymin += y;
+       rect->xmax += x;
+       rect->ymax += y;
+}
+void BLI_translate_rctf(rctf *rect, float x, float y)
+{
+       rect->xmin += x;
+       rect->ymin += y;
+       rect->xmax += x;
+       rect->ymax += y;
+}
 
 int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest)
 {
@@ -117,3 +139,33 @@ int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest)
                return 0;
        }
 }
+
+int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest)
+{
+       int xmin, xmax;
+       int ymin, ymax;
+       
+       xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
+       xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
+       ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
+       ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
+       
+       if(xmax>=xmin && ymax>=ymin) {
+               if(dest) {
+                       dest->xmin = xmin;
+                       dest->xmax = xmax;
+                       dest->ymin = ymin;
+                       dest->ymax = ymax;
+               }
+               return 1;
+       }
+       else {
+               if(dest) {
+                       dest->xmin = 0;
+                       dest->xmax = 0;
+                       dest->ymin = 0;
+                       dest->ymax = 0;
+               }
+               return 0;
+       }
+}
index 3e679cfc2324ec50885b01f65e1aa5c8f57d664b..d6ed130c9bc865b44e362ea47f4199fe7b9e2f7f 100644 (file)
@@ -781,6 +781,20 @@ void BLI_make_exist(char *dir) {
 #endif
 }
 
+void BLI_make_existing_file(char *name)
+{
+       char di[FILE_MAXDIR], fi[FILE_MAXFILE];
+       
+       strcpy(di, name);
+       BLI_splitdirstring(di, fi);
+       
+       /* test exist */
+       if (BLI_exists(di) == 0) {
+               BLI_recurdir_fileops(di);
+       }
+}
+
+
 void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file)
 {
 
@@ -1119,3 +1133,22 @@ int BLI_strncasecmp(const char *s1, const char *s2, int n) {
 
        return 0;
 }
+
+void BLI_timestr(double time, char *str)
+{
+       /* format 00:00:00.00 (hr:min:sec) string has to be 12 long */
+       int  hr= (int)      time/(60*60);
+       int min= (int) fmod(time/60, 60.0);
+       int sec= (int) fmod(time, 60.0);
+       int hun= (int) fmod(time*100.0, 100.0);
+       
+       if (hr) {
+               sprintf(str, "%.2d:%.2d:%.2d.%.2d",hr,min,sec,hun);
+       } else {
+               sprintf(str, "%.2d:%.2d.%.2d",min,sec,hun);
+       }
+       
+       str[11]=0;
+}
+
+
index dc82abc05029fb98fb392252bf71ac3c14e87fab..3cd31740520280562c34f4032d0d603deaf6c2ea 100644 (file)
@@ -1215,6 +1215,7 @@ static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
 /* library linking after fileread */
 static void lib_link_nodetree(FileData *fd, Main *main)
 {
+       Scene *sce;
        Material *ma;
        bNodeTree *ntree;
        bNode *node;
@@ -1242,6 +1243,11 @@ static void lib_link_nodetree(FileData *fd, Main *main)
                if(ma->nodetree)
                        ntreeVerifyTypes(ma->nodetree);
        }
+       /* and scene trees */
+       for(sce= main->scene.first; sce; sce= sce->id.next) {
+               if(sce->nodetree)
+                       ntreeVerifyTypes(sce->nodetree);
+       }
 }
 
 /* ntree itself has been read! */
@@ -1259,9 +1265,13 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
        for(node= ntree->nodes.first; node; node= node->next) {
                node->storage= newdataadr(fd, node->storage);
                if(node->storage) {
+                       
                        /* could be handlerized at some point, now only 1 exception still */
                        if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
                                direct_link_curvemapping(fd, node->storage);
+                       else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB))
+                               direct_link_curvemapping(fd, node->storage);
+                       
                }
                link_list(fd, &node->inputs);
                link_list(fd, &node->outputs);
@@ -2064,7 +2074,6 @@ static void direct_link_texture(FileData *fd, Tex *tex)
 static void lib_link_material(FileData *fd, Main *main)
 {
        Material *ma;
-       MaterialLayer *ml;
        MTex *mtex;
        int a;
 
@@ -2084,9 +2093,6 @@ static void lib_link_material(FileData *fd, Main *main)
                        }
                        lib_link_scriptlink(fd, &ma->id, &ma->scriptlink);
                        
-                       for (ml=ma->layers.first; ml; ml=ml->next)
-                               ml->mat= newlibadr_us(fd, ma->id.lib, ml->mat);
-                       
                        if(ma->nodetree)
                                lib_link_ntree(fd, &ma->id, ma->nodetree);
                        
@@ -2109,8 +2115,6 @@ static void direct_link_material(FileData *fd, Material *ma)
        
        direct_link_scriptlink(fd, &ma->scriptlink);
        
-       link_list(fd, &ma->layers);
-       
        ma->nodetree= newdataadr(fd, ma->nodetree);
        if(ma->nodetree)
                direct_link_nodetree(fd, ma->nodetree);
@@ -2638,6 +2642,9 @@ static void lib_link_scene(FileData *fd, Main *main)
                        
                        lib_link_scriptlink(fd, &sce->id, &sce->scriptlink);
                        
+                       if(sce->nodetree)
+                               lib_link_ntree(fd, &sce->id, sce->nodetree);
+
                        sce->id.flag -= LIB_NEEDLINK;
                }
 
@@ -2800,6 +2807,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
        }
        
        link_list(fd, &(sce->markers));
+       
+       sce->nodetree= newdataadr(fd, sce->nodetree);
+       if(sce->nodetree)
+               direct_link_nodetree(fd, sce->nodetree);
+       
 }
 
 /* ************ READ SCREEN ***************** */
@@ -2840,6 +2852,7 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                if(v3d->localvd) {
                                                        v3d->localvd->camera= newlibadr(fd, sc->id.lib, v3d->localvd->camera);
                                                }
+                                               v3d->ri= NULL;
                                        }
                                        else if(sl->spacetype==SPACE_IPO) {
                                                SpaceIpo *sipo= (SpaceIpo *)sl;
@@ -5235,6 +5248,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        }
        
        if(main->versionfile <= 240) {
+               Scene *sce;
                bArmature *arm;
                
                /* updating layers still */
@@ -5242,6 +5256,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        bone_version_239(&arm->bonebase);
                        if(arm->layer==0) arm->layer= 1;
                }
+               for(sce= main->scene.first; sce; sce= sce->id.next) {
+                       if(sce->r.xparts<2) sce->r.xparts= 4;
+                       if(sce->r.yparts<2) sce->r.yparts= 4;
+               }
        }
        
        if(main->versionfile <= 241) {
@@ -5504,7 +5522,6 @@ static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
 
 static void expand_material(FileData *fd, Main *mainvar, Material *ma)
 {
-       MaterialLayer *ml;
        int a;
 
        for(a=0; a<MAX_MTEX; a++) {
@@ -5516,11 +5533,6 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
        
        expand_doit(fd, mainvar, ma->ipo);
        
-       for (ml=ma->layers.first; ml; ml=ml->next) {
-               if(ml->mat)
-                       expand_doit(fd, mainvar, ml->mat);
-       }
-       
        if(ma->nodetree)
                expand_nodetree(fd, mainvar, ma->nodetree);
 }
index d5b3c4a29f5d8eee6bb2f1df4271f019a07db070..2bf263aa7e4205f8722071975dec52a5496161dc 100644 (file)
@@ -143,6 +143,7 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
 #include "DNA_view3d_types.h"
 #include "DNA_vfont_types.h"
 #include "DNA_userdef_types.h"
+#include "DNA_world_types.h"
 
 #include "MEM_guardedalloc.h" // MEM_freeN
 #include "BLI_blenlib.h"
@@ -391,6 +392,8 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
                        /* could be handlerized at some point, now only 1 exception still */
                        if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
                                write_curvemapping(wd, node->storage);
+                       else if(ntree->type==NTREE_COMPOSIT && (node->type==CMP_NODE_CURVE_VEC || node->type==CMP_NODE_CURVE_RGB))
+                               write_curvemapping(wd, node->storage);
                        else
                                writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
                }
@@ -1038,7 +1041,6 @@ static void write_textures(WriteData *wd, ListBase *idbase)
 static void write_materials(WriteData *wd, ListBase *idbase)
 {
        Material *ma;
-       MaterialLayer *ml;
        int a;
 
        ma= idbase->first;
@@ -1056,9 +1058,6 @@ static void write_materials(WriteData *wd, ListBase *idbase)
                        
                        write_scriptlink(wd, &ma->scriptlink);
                        
-                       for (ml=ma->layers.first; ml; ml=ml->next)
-                               writestruct(wd, DATA, "MaterialLayer", 1, ml);
-                       
                        /* nodetree is integral part of material, no libdata */
                        if(ma->nodetree) {
                                writestruct(wd, DATA, "bNodeTree", 1, ma->nodetree);
@@ -1220,6 +1219,11 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
                        marker= marker->next;
                }
                
+               if(sce->nodetree) {
+                       writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
+                       write_nodetree(wd, sce->nodetree);
+               }
+               
                sce= sce->id.next;
        }
        /* flush helps the compression for undo-save */
index a90d7d651f857f5accc65bf4a97792d88ad969c8..bd2d41881db5eadccf2c6f9f0a817f72ecbb680f 100644 (file)
@@ -197,8 +197,8 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
                        ptr = (unsigned char *)strchr((char*)&mem[x+1], '\n');
                        ptr++;
 
-                       if (flags & IB_test) ibuf = IMB_allocImBuf(width, height, 24, 0, 0);
-                       else ibuf = IMB_allocImBuf(width, height, 24, IB_rect|IB_rectfloat, 0);
+                       if (flags & IB_test) ibuf = IMB_allocImBuf(width, height, 32, 0, 0);
+                       else ibuf = IMB_allocImBuf(width, height, 32, IB_rect|IB_rectfloat, 0);
 
                        if (ibuf==NULL) return NULL;
                        ibuf->ftype = RADHDR;
@@ -224,7 +224,7 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
                                        *rect_float++ = fcol[RED];
                                        *rect_float++ = fcol[GRN];
                                        *rect_float++ = fcol[BLU];
-                                       *rect_float++ = 255;
+                                       *rect_float++ = 1.0f;
 
                                        /* Also old oldstyle for the rest of blender which is not using floats yet */
 /* very weird mapping! (ton) */
@@ -339,19 +339,28 @@ static void writeHeader(FILE *file, int width, int height)
 
 short imb_savehdr(struct ImBuf *ibuf, char *name, int flags)
 {
-       int y, width=ibuf->x, height=ibuf->y;
        FILE* file = fopen(name, "wb");
-
+       float *fp= NULL;
+       int y, width=ibuf->x, height=ibuf->y;
+       char *cp= NULL;
+       
        if (file==NULL) return 0;
 
        writeHeader(file, width, height);
 
+       if(ibuf->rect)
+               cp= (char *)(ibuf->rect + (height-1)*width);
+       if(ibuf->rect_float)
+               fp= ibuf->rect_float + 4*(height-1)*width;
+       
        for (y=height-1;y>=0;y--) {
-               if (fwritecolrs(file, width,(unsigned char *)&ibuf->rect[y*width*4], &ibuf->rect_float[y*width*4]) < 0) {
+               if (fwritecolrs(file, width, cp, fp) < 0) {
                        fclose(file);
                        printf("HDR write error\n");
                        return 0;
                }
+               if(cp) cp-= 4*width;
+               if(fp) fp-= 4*width;
        }
 
        fclose(file);
index 539ea0377b3bed0734bc9319aab12e0ab2ee6cce..c962f1fbde5a75a81d8d36f13eb0247fa3dc1280 100644 (file)
@@ -915,26 +915,33 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy)
        return(ibuf);
 }
 
+struct imbufRGBA {
+       float r, g, b, a;
+};
 
 struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy)
 {
        unsigned int *rect,*_newrect,*newrect;
-       float *rectf,*_newrectf,*newrectf;
-       int x,y, do_float=0;
+       struct imbufRGBA *rectf, *_newrectf, *newrectf;
+       int x,y, do_float=0, do_rect=0;
        int ofsx,ofsy,stepx,stepy;
 
+       rect = NULL; _newrect = NULL; newrect = NULL;
        rectf = NULL; _newrectf = NULL; newrectf = NULL;
 
        if (ibuf==NULL) return(0);
-       if (ibuf->rect==NULL) return(ibuf);
+       if (ibuf->rect) do_rect = 1;
        if (ibuf->rect_float) do_float = 1;
-
+       if (do_rect==0 && do_float==0) return(ibuf);
+       
        if (newx == ibuf->x && newy == ibuf->y) return(ibuf);
-
-       _newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf");
-       if (_newrect==NULL) return(ibuf);
-       newrect = _newrect;
-
+       
+       if(do_rect) {
+               _newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf");
+               if (_newrect==NULL) return(ibuf);
+               newrect = _newrect;
+       }
+       
        if (do_float) {
                _newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f");
                if (_newrectf==NULL) return(ibuf);
@@ -946,30 +953,34 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy)
        ofsy = 32768;
 
        for (y = newy; y > 0 ; y--){
-               rect = ibuf->rect;
-               rect += (ofsy >> 16) * ibuf->x;
+               if(do_rect) {
+                       rect = ibuf->rect;
+                       rect += (ofsy >> 16) * ibuf->x;
+               }
                if (do_float) {
-                       rectf = ibuf->rect_float;
+                       rectf = (struct imbufRGBA *)ibuf->rect_float;
                        rectf += (ofsy >> 16) * ibuf->x;
                }
                ofsy += stepy;
                ofsx = 32768;
                
                for (x = newx ; x>0 ; x--){
-                       *newrect++ = rect[ofsx >> 16];
+                       if (do_rect)  *newrect++ = rect[ofsx >> 16];
                        if (do_float) *newrectf++ = rectf[ofsx >> 16];
                        ofsx += stepx;
                }
        }
 
-       imb_freerectImBuf(ibuf);
-       ibuf->mall |= IB_rect;
-       ibuf->rect = _newrect;
+       if (do_rect) {
+               imb_freerectImBuf(ibuf);
+               ibuf->mall |= IB_rect;
+               ibuf->rect = _newrect;
+       }
        
        if (do_float) {
                imb_freerectfloatImBuf(ibuf);
                ibuf->mall |= IB_rectfloat;
-               ibuf->rect_float = _newrectf;
+               ibuf->rect_float = (float *)_newrectf;
        }
        
        scalefast_Z_ImBuf(ibuf, newx, newy);
index 522ce78ebc0ae41f0278ead026169ee9b9a00f5e..ae75de8f54f991169e3bc4e59e387ea94bb7abc8 100644 (file)
@@ -65,6 +65,8 @@
 #include "IMB_bitplanes.h"
 #include "IMB_divers.h"
 
+/* added facility to copy with saving non-float rects */
+
 short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags)
 {
        short ok=TRUE,delpl=FALSE;
@@ -75,24 +77,36 @@ short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags)
 
        /* Put formats that take a filename here */
        if (IS_jpg(ibuf)) {
+               if(ibuf->rect==NULL && ibuf->rect_float)
+                       IMB_rect_from_float(ibuf);
                return imb_savejpeg(ibuf, name, flags);
        }
        if (IS_radhdr(ibuf)) {
                return imb_savehdr(ibuf, name, flags);
        }
        if (IS_png(ibuf)) {
+               if(ibuf->rect==NULL && ibuf->rect_float)
+                       IMB_rect_from_float(ibuf);
                return imb_savepng(ibuf, name, flags);
        }
        if (IS_bmp(ibuf)) {
+               if(ibuf->rect==NULL && ibuf->rect_float)
+                       IMB_rect_from_float(ibuf);
                return imb_savebmp(ibuf, name, flags);
        }
        if (IS_tga(ibuf)) {
+               if(ibuf->rect==NULL && ibuf->rect_float)
+                       IMB_rect_from_float(ibuf);
                return imb_savetarga(ibuf, name, flags);
        }
        if (IS_iris(ibuf)) {
+               if(ibuf->rect==NULL && ibuf->rect_float)
+                       IMB_rect_from_float(ibuf);
                return imb_saveiris(ibuf, name, flags);
        }
        if (G.have_libtiff && IS_tiff(ibuf)) {
+               if(ibuf->rect==NULL && ibuf->rect_float)
+                       IMB_rect_from_float(ibuf);
                return imb_savetiff(ibuf, name, flags);
        }
 #ifdef WITH_OPENEXR
index af231de66f83b27b9e1184f408b9d73a977ee7f2..0edc73eee2df92d17de8f1e318bafbf8ff5d9b53 100644 (file)
@@ -125,7 +125,7 @@ void glaRasterPosSafe2f             (float x, float y, float known_good_x, float known_good
         * to use the glScissor functionality if images are to be drawn
         * with an inset view matrix.
         */
-void glaDrawPixelsSafe         (float x, float y, int img_w, int img_h, int format, int type, void *rect);
+void glaDrawPixelsSafe         (float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect);
 
        /**
         * Functions like a limited glDrawPixels, but actually draws the
index f2248488d81ed51332c75f4e25a323e58e71b6fe..41a5bc5e5a13fda927b607f92fdaa84426ca85e8 100644 (file)
@@ -93,6 +93,7 @@ struct ScrArea;
 #define UI_PNL_STOW            64
 #define UI_PNL_TO_MOUSE        128
 #define UI_PNL_UNSTOW  256
+#define UI_PNL_SCALE   512
 
 /* warning the first 4 flags are internal */
 /* but->flag */
@@ -288,7 +289,7 @@ void        uiButSetFunc            (uiBut *but,            void (*func)(void *arg1, void *arg2), void *arg
 
 void   uiButSetCompleteFunc(uiBut *but,                void (*func)(char *str, void *arg), void *arg);
 
-void   uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)());
+void   uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct ScrArea *sa, uiBlock *block));
 
 
 extern void pupmenu_set_active(int val);
index b8ed73505f5f2444933a7fee4091b640daca858d..dec85f5f6e7c69d63c48b829ce907158be164b13 100644 (file)
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
+#include "DNA_vec_types.h"
+
 struct SpaceButs;
 struct RenderInfo;
 struct Image;
 struct ScrArea;
+struct uiBlock;
+struct Render;
 
 #define PREVIEW_RENDERSIZE 140
 
@@ -42,11 +46,19 @@ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
 /* stores rendered preview  - is also used for icons */
 typedef struct RenderInfo {
        int pr_rectx;
-       int pr_recty;           
-       unsigned int* rect; 
-       short cury;
+       int pr_recty;
+       short cury, status;
+       rcti disprect;                  /* storage for view3d preview rect */
+       unsigned int* rect;             
+       struct Render *re;              /* persistant render */
 } RenderInfo;
 
+/* ri->status */
+#define PR_DBASE                       1
+#define PR_DISPRECT                    2
+#define PR_PROJECTED           4
+#define PR_ROTATED                     8
+
 /* Render the preview
 
 pr_method:
@@ -61,9 +73,16 @@ pr_method:
 #define PR_ICON_RENDER 1
 #define PR_DO_RENDER   2
 
-void   BIF_previewrender       (struct ID *id, struct RenderInfo *ri, struct ScrArea *area, int pr_method);
+void   BIF_previewrender               (struct ID *id, struct RenderInfo *ri, struct ScrArea *area, int pr_method);
 void   BIF_previewrender_buts  (struct SpaceButs *sbuts);
-void   BIF_previewdraw         (void);
-void    BIF_preview_changed(short id_code);
+void   BIF_previewdraw                 (struct ScrArea *sa, struct uiBlock *block);
+void    BIF_preview_changed            (short id_code);
 
+void   BIF_preview_init_dbase  (void);
+void   BIF_preview_free_dbase  (void);
 
+void   BIF_view3d_previewrender(struct ScrArea *sa);
+void   BIF_view3d_previewdraw  (struct ScrArea *sa, struct uiBlock *block);
+void   BIF_view3d_previewrender_free(struct ScrArea *sa);
+void   BIF_view3d_previewrender_clear(struct ScrArea *sa);
+void   BIF_view3d_previewrender_signal(struct ScrArea *sa, short signal);
index 6b607b110d615400c02512f59c204bfeecbf8ea1..eeb48ad8c27794fe8d9d965039e9a13a9b31d2b0 100644 (file)
@@ -32,7 +32,7 @@
 
 struct ScrArea;
 
-void calc_renderwin_rectangle(int posmask, int renderpos_r[2], int rendersize_r[2]);
+void calc_renderwin_rectangle(int rectx, int recty, int posmask, int renderpos_r[2], int rendersize_r[2]);
 
 void BIF_close_render_display(void);
 
index b47f005c2b3c5cd4caa29eb1a561c932715e2b6f..c76f961014a17f082a4e81e56a1215fd9cfb1ba6 100644 (file)
@@ -73,7 +73,7 @@ void set_g_activearea(struct ScrArea *sa);
 void getmouseco_sc(short *mval);
 void getmouseco_areawin(short *mval);
 void getmouseco_headwin(short *mval);
-unsigned short qtest(void);
+int qtest(void);
 int anyqtest(void);
 void areawinset(short win);
 void headerbox(struct ScrArea *sa);
index 2a417a385fad3f9627ec57fe66119e7d5d5de53d..3585e46c0aa3579d1e77cb3f100d053f870cd99c 100644 (file)
@@ -53,6 +53,7 @@ struct SpaceOops;
 #define VIEW3D_HANDLER_BACKGROUND      1
 #define VIEW3D_HANDLER_PROPERTIES      2
 #define VIEW3D_HANDLER_OBJECT          3
+#define VIEW3D_HANDLER_PREVIEW         4
 
 /* ipo handler codes */
 #define IPO_HANDLER_PROPERTIES 20
@@ -106,7 +107,7 @@ extern       void extern_set_butspace(int fkey);
 extern       void force_draw(int header);
 extern          void force_draw_all(int header);
 extern          void force_draw_plus(int type, int header);
-extern       void freespacelist(struct ListBase *lb);
+extern       void freespacelist(struct ScrArea *sa);
 extern       void handle_view3d_around(void);
 extern       void handle_view3d_lock(void);
 extern       void init_v2d_oops(struct ScrArea *, struct SpaceOops *);
index ef16186f15f20255c5f90a4e8c580472a3bcfbfc..f5a435d3d505d78ffbb627015f4e71c72cb92404 100644 (file)
@@ -33,9 +33,6 @@
 #ifndef BIF_TOETS_H
 #define BIF_TOETS_H
 
-void BIF_save_rendered_image(void);
-
-int save_image_filesel_str(char *str);
 int blenderqread(unsigned short event, short val);
 void persptoetsen(unsigned short event); /* dutch rules man */
 int untitled(char *name);
index 318a4294371f6767bf4373102f4cfcb9a5fe9b75..70978a033c228152fcc52c084956c52b85a0bed6 100644 (file)
 struct ImBuf;
 struct EnvMap;
 
-int BIF_write_ibuf(struct ImBuf *ibuf, char *name);
+void BIF_save_rendered_image(char *name);
+void BIF_save_rendered_image_fs(void);
 void BIF_save_envmap(struct EnvMap *env, char *str);
+void save_image_filesel_str(char *str);
 
 #endif
 
index 4a9876705e637202b0d1b9e34ef88486c8ae4135..1d04062fb8d3b96636557ff4924f18a057644d07 100644 (file)
@@ -53,12 +53,11 @@ void add_view3d_after(struct View3D *v3d, struct Base *base, int type);
 
 void backdrawview3d(int test);
 void drawview3dspace(struct ScrArea *sa, void *spacedata);
-void drawview3d_render(struct View3D *v3d);
+void drawview3d_render(struct View3D *v3d, int winx, int winy);
 
 int update_time(void);
 void calc_viewborder(struct View3D *v3d, struct rcti *viewborder_r);
 void view3d_set_1_to_1_viewborder(struct View3D *v3d);
-void timestr(double time, char *str);
 
 int view3d_test_clipping(struct View3D *v3d, float *vec);
 void view3d_set_clipping(struct View3D *v3d);
index c5393f2e69ecc7e20467445d8a4fedbe3bf5ca60..7ad973d49153d0ae5df4b2f766eac54591331eec 100644 (file)
@@ -43,6 +43,7 @@ struct bNode;
 struct bNodeTree;
 struct Material;
 struct ID;
+struct Scene;
 
 /* ************* API for editnode.c *********** */
 
@@ -58,9 +59,12 @@ void snode_set_context(struct SpaceNode *snode);
 void node_deselectall(struct SpaceNode *snode, int swap);
 void node_transform_ext(int mode, int unused);
 void node_shader_default(struct Material *ma);
+void node_composit_default(struct Scene *scene);
 
 int node_has_hidden_sockets(struct bNode *node);
 
+struct bNode *node_add_node(struct SpaceNode *snode, int type, float locx, float locy);
+
 /* ************* drawnode.c *************** */
 void node_draw_link(struct SpaceNode *snode, struct bNodeLink *link);
 
@@ -68,7 +72,6 @@ void init_node_butfuncs(void);
 
 /* ************* Shader nodes ***************** */
 
-struct bNode *node_add_shadernode(struct SpaceNode *snode, int type, float locx, float locy);
 
 #endif
 
index 994559e6194c04f4e0a239c400bcb9631896c3df..df38389892aef63a0aa8ce6285a52cb8b880968e 100644 (file)
@@ -125,11 +125,14 @@ struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
 void set_meta_stripdata(struct Sequence *seqm);
 void do_seq_count_cfra(struct ListBase *seqbase, int *totseq, int cfra);
 void do_build_seqar_cfra(struct ListBase *seqbase, struct Sequence ***seqar, int cfra);
-struct ImBuf *give_ibuf_seq(int cfra);
+struct ImBuf *give_ibuf_seq(int rectx, int recty, int cfra);
 void free_imbuf_effect_spec(int cfra);
 void free_imbuf_seq_except(int cfra);
 void free_imbuf_seq(void);
-void do_render_seq(void);
+
+/* still bad level call... */
+struct RenderResult;
+void do_render_seq(struct RenderResult *rr);
 
 
 #endif
index e241f92143bff904fb3154b890b86baaf90839a8..2afbca2b30eb0cc053447b4a267d84ef0a834e28 100644 (file)
@@ -68,7 +68,10 @@ void sdrawbox(short x1, short y1, short x2, short y2);
 void calctrackballvecfirst(struct rcti *area, short *mval, float *vec);
 void calctrackballvec(struct rcti *area, short *mval, float *vec);
 void viewmove(int mode);
-void setwinmatrixview3d(struct rctf *rect);
+
+int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend);
+void setwinmatrixview3d(int winx, int winy, struct rctf *rect);
+
 void obmat_to_viewmat(struct Object *ob);
 void setviewmatrixview3d(void);
 float *give_cursor(void);
index 67767cf661312fb9e008a0e251efe1e3f31e78bc..52638e6f9889e6e2888cc873735274f70c45babe 100644 (file)
 /* NODE: 851-900 */
 #define B_NODEHOME                     851
 #define B_NODE_USEMAT          852
+#define B_NODE_USESCENE                853
 
 /* FREE 901 - 999 */
 
index 2ae3054a1abc1e156f3b3fdf2ce1e469bac023ee..aca652d52bdd52642cb24a74e96ab6eed83e1c4e 100644 (file)
@@ -127,6 +127,7 @@ void test_scriptpoin_but(char *name, struct ID **idpp);
 void test_actionpoin_but(char *name, ID **idpp);
 void test_grouppoin_but(char *name, ID **idpp);
 void test_texpoin_but(char *name, ID **idpp);
+void test_imapoin_but(char *name, ID **idpp);
 
 void test_idbutton_cb(void *namev, void *arg2_unused);
 
@@ -195,7 +196,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
 #define B_MAT_USENODES         1221
                /* also handled in editnode.c */
 #define B_NODE_EXEC                    1222
-
+#define B_NODE_LOADIMAGE       1223
 
 /* *********************** */
 #define B_TEXBUTS              1400
index 15f2e8ee010cfe7966e673186b7d3239e456d214..f2f6aad855d7396be3e1c657d76e8603d86f1137 100644 (file)
 #define UI_MAX_NAME_STR        64
 #define UI_ARRAY       29
 
+/* panel limits */
+#define UI_PANEL_MINX  100
+#define UI_PANEL_MINY  70
+
 /* uiBut->flag */
 #define UI_SELECT              1
 #define UI_MOUSE_OVER  2
@@ -202,6 +206,7 @@ struct uiBlock {
 /* interface.c */
 
 extern void ui_graphics_to_window(int win, float *x, float *y);
+extern void ui_graphics_to_window_rct(int win, rctf *graph, rcti *winr);
 extern void ui_window_to_graphics(int win, float *x, float *y);
 
 extern void ui_block_flush_back(uiBlock *block);
@@ -216,6 +221,7 @@ extern void ui_autofill(uiBlock *block);
 /* interface_panel.c */
 extern void ui_draw_panel(uiBlock *block);
 extern void ui_do_panel(uiBlock *block, uiEvent *uevent);
+extern void ui_scale_panel(uiBlock *block);
 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
 
index 7b26a3c2b570c62d147900ccc5c3d4e4a2b71931..a6dca412d9c45353e111908e23d9c67a16b7c01e 100644 (file)
@@ -50,7 +50,7 @@ typedef struct Image {
        struct ImBuf *mipmap[10];
        
        short ok, flag;
-       short lastframe, lastquality;
+       short lastframe, pad;
 
        /* texture page */
        short tpageflag, totbind;
index 6d8527d5896bce153fdef9041c789de10085b3fb..15cee1a288e7d7b10bedcbc246d4eb7819d419ff 100644 (file)
@@ -49,16 +49,6 @@ struct ColorBand;
 struct Group;
 struct bNodeTree;
 
-typedef struct MaterialLayer {
-       struct MaterialLayer *next, *prev;
-       
-       struct Material *mat;
-       float blendfac;
-       short flag, blendmethod, menunr, pad;
-       int pad2;
-       
-} MaterialLayer;
-
 /* WATCH IT: change type? also make changes in ipo.h  */
 
 typedef struct Material {
@@ -109,7 +99,6 @@ typedef struct Material {
        float rampfac_col, rampfac_spec;
 
        struct MTex *mtex[10];
-       ListBase layers;
        struct bNodeTree *nodetree;     
        struct Ipo *ipo;
        struct Group *group;    /* light group */
@@ -247,20 +236,14 @@ typedef struct Material {
 #define MAP_LAYER              16384
 
 /* pr_type */
-#define MA_FLAT                        0
-#define MA_SPHERE              1
-#define MA_CUBE                        2
+#define MA_SPHERE              0
+#define MA_CUBE                        1
+#define MA_FLAT                        2
+#define MA_MONKEY              3
+#define MA_SPHERE_A            4
 
 /* pr_back */
 #define MA_DARK                        1
 
-/* MaterialLayer flag */
-#define ML_ACTIVE              1
-#define ML_RENDER              2
-#define ML_NEG_NORMAL  4
-#define ML_DIFFUSE             8
-#define ML_SPECULAR            16
-#define ML_ALPHA               32
-
 #endif
 
index 85db0887f519002dc4b698aab168c6cb33f550a4..783a7bb05a530a5b8689993c5b4af217f9b7b733 100644 (file)
@@ -47,9 +47,10 @@ typedef struct bNodeStack {
        float vec[4];
        float min, max;                 /* min/max for values (UI writes it, execute might use it) */
        void *data;
-       short hasinput;                 /* hasinput is tagged before executing */
+       short hasinput;                 /* when input has link, tagged before executing */
+       short hasoutput;                /* when output is linked, tagged before executing */
        short datatype;                 /* type of data pointer */
-       int pad1;
+       short pad1;
 } bNodeStack;
 
 /* ns->datatype, shadetree only */
@@ -157,7 +158,8 @@ typedef struct bNodeTree {
        bNodeStack *stack1;                             /* for other thread, easy to expand though... */
        
        int type, init;                                 /* set init on fileread */
-       int cur_index, pad;                             /* sockets in groups have unique identifiers, adding new sockets always will increase this counter */
+       int stacksize;                                  /* amount of elements in stack */
+       int cur_index;                                  /* sockets in groups have unique identifiers, adding new sockets always will increase this counter */
        struct bNodeType **alltypes;    /* type definitions, set on fileread, no read/write */
        struct bNodeType *owntype;              /* for groups or dynamic trees, no read/write */
        
index 0f1cdb8368fa03838f6cd2bda2a275a69ac238e9..c34b14f30af5b1539b93c5652dee16d83fdd8e82 100644 (file)
@@ -335,7 +335,7 @@ extern Object workob;
 #define BA_DO_IPO                      32
 
 #define BA_FROMSET                     128
-#define OB_DO_IMAT                     256
+
 #define OB_FROMDUPLI           512
 #define OB_DONE                                1024
 #define OB_RADIO                       2048
index 12de019dd16b38b8e6ece0850f06940a9da91065..3f84b812cfb370370d9842d69c34de999253ff93 100644 (file)
@@ -48,6 +48,7 @@ struct World;
 struct Scene;
 struct Image;
 struct Group;
+struct bNodeTree;
 
 typedef struct Base {
        struct Base *next, *prev;
@@ -294,9 +295,12 @@ typedef struct Scene {
        unsigned int lay;
        
        /* editmode stuff */
-       short selectmode, pad;
-       short proportional, prop_mode;
        float editbutsize;                      /* size of normals */
+       short selectmode;
+       short proportional, prop_mode;
+       
+       short use_nodes;
+       struct bNodeTree *nodetree;     
        
        void *ed;
        struct Radio *radio;
@@ -318,7 +322,7 @@ typedef struct Scene {
        /* none of the dependancy graph  vars is mean to be saved */
        struct  DagForest *theDag;
        short dagisvalid, dagflags;
-       int dirty;
+       short dirty, recalc;                            /* recalc = counterpart of ob->recalc */
 } Scene;
 
 
@@ -374,7 +378,7 @@ typedef struct Scene {
 #define R_PASSEPARTOUT 0x0004
 
 #define R_EXTENSION            0x0010
-#define R_OGL                  0x0020
+#define R_NODE_PREVIEW 0x0020
 
 /* alphamode */
 #define R_ADDSKY               0
@@ -428,6 +432,9 @@ typedef struct Scene {
 #define SCE_CLEAN           0
 #define SCE_DIRTY           1
 
+/* sce->recalc (now in use by previewrender) */
+#define SCE_PRV_CHANGED                1
+
 /* sce->prop_mode (proportional falloff) */
 #define PROP_SMOOTH            0
 #define PROP_SPHERE            1
index 9a5fd12dd0f64771a6a50db0c87611f0e567d9a9..03c6aad6cf60d156ecaebfae9aef45de97e87159 100644 (file)
@@ -40,6 +40,7 @@ struct Tex;
 struct SpaceLink;
 struct Base;
 struct BoundBox;
+struct RenderInfo;
 
 /* This is needed to not let VC choke on near and far... old
  * proprietary MS extensions... */
@@ -92,6 +93,7 @@ typedef struct View3D {
        struct Object *camera;
        struct BGpic *bgpic;
        struct View3D *localvd;
+       struct RenderInfo *ri;
        
        /**
         * The drawing mode for the 3d display. Set to OB_WIRE, OB_SOLID,
index 157f2e19cb70745ae1cd0008869f867e30f4bf38..30fbc22214a0c4ea5b49d4cbabd73e1faf03c72f 100644 (file)
 #include "BLI_blenlib.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
+#include "DNA_object_types.h"
 #include "DNA_material_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
 #include "MTex.h"
 #include "Image.h"
 #include "Ipo.h"
 #include "constant.h"
 #include "blendef.h"
-#include "render.h"
 #include "gen_utils.h"
 
 /*****************************************************************************/
@@ -1863,7 +1865,7 @@ static int Texture_setType( BPy_Texture * self, PyObject * value )
 
        if( !err && self->texture->type == TEX_ENVMAP 
                        && !self->texture->env ) {
-               self->texture->env = RE_add_envmap();
+               self->texture->env = BKE_add_envmap();
                self->texture->env->object= OBACT;
        }
        return err;
@@ -2541,7 +2543,7 @@ static PyObject *Texture_oldsetType( BPy_Texture * self, PyObject * args )
 
        if( self->texture->type == TEX_ENVMAP 
                        && !self->texture->env ) {
-               self->texture->env = RE_add_envmap();
+               self->texture->env = BKE_add_envmap();
                self->texture->env->object= OBACT;
        }
 
index 4ad440ee476a2faf50a0dec182373a148fe5e2f0..01329dd36c4fd0469273c72daafb226dda8284c2 100644 (file)
@@ -33,15 +33,20 @@ struct View3D; /* keep me up here */
 
 #include "sceneRender.h" /*This must come first*/
 
-#include "BIF_renderwin.h"
 #include "DNA_image_types.h"
-#include "BIF_drawscene.h"
-#include "BLI_blenlib.h"
+
 #include "BKE_image.h"
 #include "BKE_global.h"
+
+#include "BIF_drawscene.h"
+#include "BIF_renderwin.h"
+
+#include "BLI_blenlib.h"
+
+#include "RE_pipeline.h"
+
 #include "mydevice.h"
 #include "butspace.h"
-#include "render.h" /* RE_animrender() */
 #include "blendef.h"
 #include "gen_utils.h"
 
@@ -55,8 +60,6 @@ struct View3D; /* keep me up here */
 #define PY_SKYDOME     1
 #define PY_FULL         2
 
-extern RE_Render R;
-extern void schrijfplaatje(char *name);
 extern void waitcursor(int);
 
 //---------------------------------------Render prototypes-------------
@@ -872,6 +875,7 @@ PyObject *RenderData_Render( BPy_RenderData * self )
        }
 
        else { /* background mode (blender -b file.blend -P script) */
+               Render *re= RE_NewRender("Render");
 
                int end_frame = G.scene->r.efra; /* is of type short currently */
 
@@ -881,7 +885,7 @@ PyObject *RenderData_Render( BPy_RenderData * self )
 
                G.scene->r.efra = G.scene->r.sfra;
 
-               RE_animrender(NULL);
+               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
 
                G.scene->r.efra = (short)end_frame;
        }
@@ -907,7 +911,7 @@ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
        BLI_strncpy( filepath, self->renderContext->pic, sizeof(filepath) );
        strcat(filepath, name_str);
        
-       if(!R.rectot) {
+       if(0) {//!R.rectot) {
                return EXPP_ReturnPyObjError (PyExc_RuntimeError,
                        "No image rendered");
        } else {
@@ -917,9 +921,9 @@ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
                        strcpy(G.ima, dir);
                }
                
-               R.r.imtype= G.scene->r.imtype;
-               R.r.quality= G.scene->r.quality;
-               R.r.planes= G.scene->r.planes;
+//             R.r.imtype= G.scene->r.imtype;
+//             R.r.quality= G.scene->r.quality;
+//             R.r.planes= G.scene->r.planes;
        
                strcpy(strn, filepath);
                BLI_convertstringcode(strn, G.sce, G.scene->r.cfra);
@@ -929,7 +933,7 @@ PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
                }
 
                waitcursor(1);
-               schrijfplaatje(strn);
+//             schrijfplaatje(strn);
                strcpy(G.ima, filepath);
                waitcursor(0);
        }
@@ -948,6 +952,8 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
                set_scene( oldsce );
        }
        else { /* background mode (blender -b file.blend -P script) */
+               Render *re= RE_NewRender("Render");
+               
                if (G.scene != self->scene)
                        return EXPP_ReturnPyObjError (PyExc_RuntimeError,
                                "scene to render in bg mode must be the active scene");
@@ -955,7 +961,8 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
                if (G.scene->r.sfra > G.scene->r.efra)
                        return EXPP_ReturnPyObjError (PyExc_RuntimeError,
                                "start frame must be less or equal to end frame");
-               RE_animrender(NULL);
+               
+               RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
        }
        return EXPP_incr_ret( Py_None );
 }
@@ -975,7 +982,7 @@ PyObject *RenderData_Play( BPy_RenderData * self )
                strcpy( file, self->renderContext->pic );
                BLI_convertstringcode( file, (char *) self->scene,
                                       self->renderContext->cfra );
-               RE_make_existing_file( file );
+               BLI_make_existing_file( file );
                if( BLI_strcasecmp( file + strlen( file ) - 4, ".mov" ) ) {
                        sprintf( txt, "%04d_%04d.mov",
                                 ( self->renderContext->sfra ),
@@ -989,7 +996,7 @@ PyObject *RenderData_Play( BPy_RenderData * self )
                strcpy( file, self->renderContext->pic );
                BLI_convertstringcode( file, G.sce,
                                       self->renderContext->cfra );
-               RE_make_existing_file( file );
+               BLI_make_existing_file( file );
                if( BLI_strcasecmp( file + strlen( file ) - 4, ".avi" ) ) {
                        sprintf( txt, "%04d_%04d.avi",
                                 ( self->renderContext->sfra ),
@@ -998,14 +1005,14 @@ PyObject *RenderData_Play( BPy_RenderData * self )
                }
        }
        if( BLI_exist( file ) ) {
-               calc_renderwin_rectangle( G.winpos, pos, size );
+               calc_renderwin_rectangle(640, 480, 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 );
+               BKE_makepicstring( file, self->renderContext->sfra );
                if( BLI_exist( file ) ) {
-                       calc_renderwin_rectangle( G.winpos, pos, size );
+                       calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
                        sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
                                 pos[0], pos[1], file );
                        system( str );
index 5c59f73434596fde3f18bc374550b99ca484863a..462ee77cf25dc1a0131001047c141cd725b3666a 100644 (file)
 #ifdef WITH_QUICKTIME
 #if defined(_WIN32) || defined(__APPLE__)
 
+#include "DNA_scene_types.h"
+
 #include "BKE_global.h"
 #include "BKE_scene.h"
+
 #include "BLI_blenlib.h"
 #include "BIF_toolbox.h"       /* error() */
+
 #include "BLO_sys_types.h"
+
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
+
 #include "MEM_guardedalloc.h"
-#include "render.h"
+
 #include "quicktime_import.h"
 #include "quicktime_export.h"
 
 #define        kTrackStart             0
 #define        kMediaStart             0
 
-static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame);
-static void QT_DoAddVideoSamplesToMedia (int frame);
+static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, int recty);
+static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int recty);
 static void QT_EndAddVideoSamplesToMedia (void);
-static void QT_CreateMyVideoTrack (void);
+static void QT_CreateMyVideoTrack (int rectx, int recty);
 static void QT_EndCreateMyVideoTrack (void);
 static void check_renderbutton_framerate(void);
 
@@ -249,7 +255,7 @@ static OSErr QT_AddUserDataTextToMovie (Movie theMovie, char *theText, OSType th
 }
 
 
-static void QT_CreateMyVideoTrack(void)
+static void QT_CreateMyVideoTrack(int rectx, int recty)
 {
        OSErr err = noErr;
        Rect trackFrame;
@@ -257,8 +263,8 @@ static void QT_CreateMyVideoTrack(void)
 
        trackFrame.top = 0;
        trackFrame.left = 0;
-       trackFrame.bottom = R.recty;
-       trackFrame.right = R.rectx;
+       trackFrame.bottom = recty;
+       trackFrame.right = rectx;
        
        qtexport->theTrack = NewMovieTrack (qtexport->theMovie, 
                                                        FixRatio(trackFrame.right,1),
@@ -281,7 +287,7 @@ static void QT_CreateMyVideoTrack(void)
        err = BeginMediaEdits (qtexport->theMedia);
        CheckError( err, "BeginMediaEdits error" );
 
-       QT_StartAddVideoSamplesToMedia (&trackFrame);
+       QT_StartAddVideoSamplesToMedia (&trackFrame, rectx, recty);
 } 
 
 
@@ -303,19 +309,19 @@ static void QT_EndCreateMyVideoTrack(void)
 } 
 
 
-static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame)
+static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, int recty)
 {
        OSErr err = noErr;
 
-       qtexport->ibuf = IMB_allocImBuf (R.rectx, R.recty, 32, IB_rect, 0);
-       qtexport->ibuf2 = IMB_allocImBuf (R.rectx, R.recty, 32, IB_rect, 0);
+       qtexport->ibuf = IMB_allocImBuf (rectx, recty, 32, IB_rect, 0);
+       qtexport->ibuf2 = IMB_allocImBuf (rectx, recty, 32, IB_rect, 0);
 
        err = NewGWorldFromPtr( &qtexport->theGWorld,
                                                        k32ARGBPixelFormat,
                                                        trackFrame,
                                                        NULL, NULL, 0,
                                                        (unsigned char *)qtexport->ibuf->rect,
-                                                       R.rectx * 4 );
+                                                       rectx * 4 );
        CheckError (err, "NewGWorldFromPtr error");
 
        qtexport->thePixMap = GetGWorldPixMap(qtexport->theGWorld);
@@ -332,7 +338,7 @@ static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame)
 }
 
 
-static void QT_DoAddVideoSamplesToMedia (int frame)
+static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int recty)
 {
        OSErr   err = noErr;
        Rect    imageRect;
@@ -348,7 +354,7 @@ static void QT_DoAddVideoSamplesToMedia (int frame)
 
 
        //copy and flip renderdata
-       memcpy(qtexport->ibuf2->rect, R.rectot, 4*R.rectx*R.recty);
+       memcpy(qtexport->ibuf2->rect, pixels, 4*rectx*recty);
        IMB_flipy(qtexport->ibuf2);
 
        //get pointers to parse bitmapdata
@@ -359,7 +365,7 @@ static void QT_DoAddVideoSamplesToMedia (int frame)
        to = (unsigned char *) myPtr;
 
        //parse RGBA bitmap into Quicktime's ARGB GWorld
-       boxsize = R.rectx * R.recty;
+       boxsize = rectx * recty;
        for( index = 0; index < boxsize; index++) {
                to[0] = from[3];
                to[1] = from[0];
@@ -415,7 +421,7 @@ void makeqtstring (char *string) {
        strcpy(string, G.scene->r.pic);
        BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
 
-       RE_make_existing_file(string);
+       BLI_make_existing_file(string);
 
        if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) {
                sprintf(txt, "%04d_%04d.mov", (G.scene->r.sfra) , (G.scene->r.efra) );
@@ -424,7 +430,7 @@ void makeqtstring (char *string) {
 }
 
 
-void start_qt(void) {
+void start_qt(struct RenderData *rd, int rectx, int recty) {
        OSErr err = noErr;
 
        char name[2048];
@@ -446,7 +452,7 @@ void start_qt(void) {
 
        qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeCodecDataExt");
 
-       if(G.scene->r.qtcodecdata == NULL && G.scene->r.qtcodecdata->cdParms == NULL) {
+       if(rd->qtcodecdata == NULL && rd->qtcodecdata->cdParms == NULL) {
                get_qtcodec_settings();
        } else {
                qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
@@ -456,7 +462,7 @@ void start_qt(void) {
        }
        
        if (G.afbreek != 1) {
-               sframe = (G.scene->r.sfra);
+               sframe = (rd->sfra);
 
                makeqtstring(name);
 
@@ -499,14 +505,14 @@ void start_qt(void) {
                } else {
                        printf("Created QuickTime movie: %s\n", name);
 
-                       QT_CreateMyVideoTrack();
+                       QT_CreateMyVideoTrack(rectx, recty);
                }
        }
 }
 
 
-void append_qt(int frame) {
-       QT_DoAddVideoSamplesToMedia(frame);
+void append_qt(int frame, int *pixels, int rectx, int recty) {
+       QT_DoAddVideoSamplesToMedia(frame, pixels, rectx, recty);
 }
 
 
index 3ecea889fa60696042345bb997006bb0714d5101..5962ae3d713ffff04abefec08a796e695e611dfd 100644 (file)
 #define __AIFF__
 
 // quicktime movie output functions
+struct RenderData;
 
-void start_qt(void);                                   //for initrender.c
-void append_qt(int frame);
+void start_qt(struct RenderData *rd, int rectx, int recty);    //for movie handle (BKE writeavi.c now)
+void append_qt(int frame, int *pixels, int rectx, int recty);
 void end_qt(void);
 
 int  get_qtcodec_settings(void);               //for buttons.c
index 6aef7396fd04a5935bf426f47271c388a634e9c9..0c7205e6a830fb574bf593e988466ed5293d1b1e 100644 (file)
@@ -18,7 +18,8 @@ rad_env.Append (CPPPATH = ['extern/include',
                            '../makesdna',
                            '../include',
                            '#/intern/guardedalloc',
-                           '../render/extern/include'])
+                           '../render/extern/include',
+                           '../render/intern/include'])
 
 rad_env.Append (CPPPATH = user_options_dict['OPENGL_INCLUDE'])
 
index 81fd9fdda2eab999694aa97b650368f4d46d0431..23aa30e3bdaf80a2eb787c3bb57bf8650bc16a87 100644 (file)
@@ -166,7 +166,8 @@ extern void drawpatch_ext(RPatch *patch, unsigned int col);
 extern void RAD_drawall(int depth_is_on);
 
 /* radrender.c */
-extern void do_radio_render(void);
+struct Render;
+extern void do_radio_render(struct Render *re);
 void end_radio_render(void);
 
 #endif /* RADIO_H */
index 442e00cb8edc628801dff3ad09663dd91f59cdc8..ae1f1e4f7eee33996b0c0ab65fcc5ab12dbf6c22 100644 (file)
@@ -41,6 +41,8 @@
 #include "DNA_listBase.h" 
 #include "DNA_material_types.h" 
 
+struct Render;
+
 #define DTWIRE         0
 #define DTGOUR         2
 #define DTSOLID                1
@@ -162,6 +164,7 @@ typedef struct {
        float elemmin, elemmax;
        float radfactor, lostenergy, igamma;            /* radfac is in button, radfactor is calculated */
        int phase;
+       struct Render *re;                                                      /* for calling hemizbuf correctly */
        /* to preserve materials as used before, max 16 */
        Material *matar[MAXMAT];
        int totmat;
index fd2ff50ca418681e16a0fb2bcab2610537776556..54a3af8e0985431c0f668aee197eaf87abd7d9a7 100644 (file)
@@ -57,3 +57,4 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
 # third is the external interface. there should be a nicer way to say this 
 CPPFLAGS += -I../include -I../../../include -I../../extern/include
 CPPFLAGS += -I../../../render/extern/include 
+CPPFLAGS += -I../../../render/intern/include 
index cbe861fa44385a225175b38761c4ad11135d047f..64beea24d233aec88a997532f4c5405e64f29bce 100644 (file)
 #include "BIF_screen.h"
 
 #include "radio.h"
-#include "render.h"       /* for `RE_zbufferall_radio and RE_zbufferall_radio */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "RE_render_ext.h"       /* for `RE_zbufferall_radio and RE_zbufferall_radio */
 
 /* locals */
 void rad_setmatrices(RadView *vw);
@@ -290,7 +286,7 @@ void hemizbuf(RadView *vw)
        int a, b, inda, hres;
 
        rad_setmatrices(vw);
-       RE_zbufferall_radio(vw, RG.elem, RG.totelem);
+       RE_zbufferall_radio(vw, RG.elem, RG.totelem, RG.re);    /* Render for when we got renderfaces */
 
        /* count factors */
        if(vw->recty==vw->rectx) factors= RG.topfactors;
index 923ab69db6e173b0ee90d5a299dc5a654d879fe9..21292e14df3c1e08816580add48a6ddd6a9c96ff 100644 (file)
@@ -238,6 +238,8 @@ void set_radglobal()
        RG.gamma= rad->gamma;
        RG.maxiter= rad->maxiter;
        
+       RG.re= NULL;    /* struct render, for when call it from render engine */
+       
        rad_setlimits();
 }
 
index a6ff8657d0c76f88ea5771bb45503d496f8ebc75..ffb896a8c499b054b89e3c3f5295197a0bc43903 100644 (file)
 #include "BIF_screen.h"
 
 #include "radio.h"
-#include "render.h" 
+
+/* the radiosity module uses internal includes from render! */
+#include "renderpipeline.h" 
+#include "render_types.h" 
+#include "renderdatabase.h" 
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -80,7 +84,7 @@ static float maxenergy;
 
 /* find the face with maximum energy to become shooter */
 /* nb: _rr means rad-render version of existing radio call */
-static VlakRen *findshoot_rr(void)
+static VlakRen *findshoot_rr(Render *re)
 {
        RadFace *rf;
        VlakRen *vlr=NULL, *shoot;
@@ -90,8 +94,8 @@ static VlakRen *findshoot_rr(void)
        shoot= NULL;
        maxenergy= 0.0;
        
-       for(a=0; a<R.totvlak; a++) {
-               if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++;
+       for(a=0; a<re->totvlak; a++) {
+               if((a & 255)==0) vlr= re->blovl[a>>8]; else vlr++;
                if(vlr->radface) {
                        rf= vlr->radface;
                        rf->flag &= ~RAD_SHOOT;
@@ -116,7 +120,7 @@ static VlakRen *findshoot_rr(void)
        return shoot;
 }
 
-static void backface_test_rr(VlakRen *shoot)
+static void backface_test_rr(Render *re, VlakRen *shoot)
 {
        VlakRen *vlr=NULL;
        RadFace *rf;
@@ -124,8 +128,8 @@ static void backface_test_rr(VlakRen *shoot)
        int a;
        
        /* backface testing */
-       for(a=0; a<R.totvlak; a++) {
-               if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++;
+       for(a=0; a<re->totvlak; a++) {
+               if((a & 255)==0) vlr= re->blovl[a>>8]; else vlr++;
                if(vlr->radface) {
                        if(vlr!=shoot) {
                                rf= vlr->radface;
@@ -139,15 +143,15 @@ static void backface_test_rr(VlakRen *shoot)
        }
 }
 
-static void clear_backface_test_rr()
+static void clear_backface_test_rr(Render *re)
 {
        VlakRen *vlr=NULL;
        RadFace *rf;
        int a;
        
        /* backface flag clear */
-       for(a=0; a<R.totvlak; a++) {
-               if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++;
+       for(a=0; a<re->totvlak; a++) {
+               if((a & 255)==0) vlr= re->blovl[a>>8]; else vlr++;
                
                if(vlr->radface) {
                        rf= vlr->radface;
@@ -159,7 +163,7 @@ static void clear_backface_test_rr()
 extern RadView hemitop, hemiside; // radfactors.c
 
 /* hemi-zbuffering, delivers formfactors array */
-static void makeformfactors_rr(VlakRen *shoot)
+static void makeformfactors_rr(Render *re, VlakRen *shoot)
 {
        VlakRen *vlr=NULL;
        RadFace *rf;
@@ -203,8 +207,8 @@ static void makeformfactors_rr(VlakRen *shoot)
        /* convert factors to real radiosity */
        fp= RG.formfactors;
 
-       for(a=0; a<R.totvlak; a++) {
-               if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++;
+       for(a=0; a<re->totvlak; a++) {
+               if((a & 255)==0) vlr= re->blovl[a>>8]; else vlr++;
                
                if(vlr->radface) {
                        rf= vlr->radface;
@@ -218,7 +222,7 @@ static void makeformfactors_rr(VlakRen *shoot)
 }
 
 /* based at RG.formfactors array, distribute shoot energy over other faces */
-static void applyformfactors_rr(VlakRen *shoot)
+static void applyformfactors_rr(Render *re, VlakRen *shoot)
 {
        VlakRen *vlr=NULL;
        RadFace *rf;
@@ -231,8 +235,8 @@ static void applyformfactors_rr(VlakRen *shoot)
 
        fp= RG.formfactors;
        
-       for(a=0; a<R.totvlak; a++) {
-               if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++;
+       for(a=0; a<re->totvlak; a++) {
+               if((a & 255)==0) vlr= re->blovl[a>>8]; else vlr++;
                
                if(vlr->radface) {
                        rf= vlr->radface;
@@ -263,52 +267,51 @@ static void applyformfactors_rr(VlakRen *shoot)
 
 
 /* main loop for itterations */
-static void progressiverad_rr()
+static void progressiverad_rr(Render *re)
 {
-       extern void RE_local_timecursor(int);   // RE_callbacks.c
        VlakRen *shoot;
        float unshot[3];
        int it= 0;
        
-       shoot= findshoot_rr();
+       shoot= findshoot_rr(re);
        while( shoot ) {
                
                /* backfaces receive no energy, but are zbuffered... */
-               backface_test_rr(shoot);
+               backface_test_rr(re, shoot);
                
                /* ...unless it's two sided */
                if(shoot->radface->flag & RAD_TWOSIDED) {
                        VECCOPY(unshot, shoot->radface->unshot);
                        VecMulf(shoot->radface->norm, -1.0);
-                       makeformfactors_rr(shoot);
-                       applyformfactors_rr(shoot);
+                       makeformfactors_rr(re, shoot);
+                       applyformfactors_rr(re, shoot);
                        VecMulf(shoot->radface->norm, -1.0);