Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/CMakeLists.txt1
-rw-r--r--source/blender/Makefile2
-rw-r--r--source/blender/SConscript1
-rw-r--r--source/blender/blenkernel/BKE_exotic.h1
-rw-r--r--source/blender/blenkernel/BKE_particle.h5
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h56
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h8
-rw-r--r--source/blender/blenkernel/intern/blender.c1
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c18
-rw-r--r--source/blender/blenkernel/intern/exotic.c593
-rw-r--r--source/blender/blenkernel/intern/multires.c6
-rw-r--r--source/blender/blenkernel/intern/particle.c48
-rw-r--r--source/blender/blenkernel/intern/particle_system.c187
-rw-r--r--source/blender/blenkernel/intern/pointcache.c753
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenlib/intern/storage.c12
-rw-r--r--source/blender/blenlib/intern/util.c5
-rw-r--r--source/blender/blenloader/intern/readfile.c32
-rw-r--r--source/blender/blenloader/intern/writefile.c21
-rw-r--r--source/blender/blenpluginapi/intern/Makefile4
-rw-r--r--source/blender/editors/include/ED_pointcache.h (renamed from source/blender/makesdna/DNA_radio_types.h)42
-rw-r--r--source/blender/editors/physics/ed_pointcache.c270
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c153
-rw-r--r--source/blender/editors/space_api/spacetypes.c2
-rw-r--r--source/blender/editors/space_buttons/SConscript3
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c12
-rw-r--r--source/blender/editors/space_info/SConscript3
-rw-r--r--source/blender/editors/space_logic/SConscript3
-rw-r--r--source/blender/editors/space_view3d/drawobject.c3
-rw-r--r--source/blender/editors/transform/transform_conversions.c2
-rw-r--r--source/blender/editors/transform/transform_input.c1
-rw-r--r--source/blender/editors/transform/transform_ndofinput.c1
-rw-r--r--source/blender/editors/transform/transform_numinput.c1
-rw-r--r--source/blender/gpu/intern/Makefile2
-rw-r--r--source/blender/imbuf/intern/imbuf.h2
-rw-r--r--source/blender/imbuf/intern/readimage.c21
-rw-r--r--source/blender/makesdna/DNA_object_force.h19
-rw-r--r--source/blender/makesdna/DNA_particle_types.h1
-rw-r--r--source/blender/makesdna/DNA_scene_types.h4
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h31
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
-rw-r--r--source/blender/makesrna/RNA_access.h4
-rw-r--r--source/blender/makesrna/RNA_enum_types.h3
-rw-r--r--source/blender/makesrna/intern/makesrna.c1
-rw-r--r--source/blender/makesrna/intern/rna_access.c31
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c105
-rw-r--r--source/blender/makesrna/intern/rna_particle.c94
-rw-r--r--source/blender/makesrna/intern/rna_radio.c140
-rw-r--r--source/blender/makesrna/intern/rna_scene.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c25
-rw-r--r--source/blender/makesrna/intern/rna_wm.c202
-rw-r--r--source/blender/makesrna/intern/rna_world.c2
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c97
-rw-r--r--source/blender/radiosity/CMakeLists.txt36
-rw-r--r--source/blender/radiosity/Makefile34
-rw-r--r--source/blender/radiosity/SConscript12
-rw-r--r--source/blender/radiosity/extern/include/radio.h173
-rw-r--r--source/blender/radiosity/extern/include/radio_types.h168
-rw-r--r--source/blender/radiosity/intern/Makefile34
-rw-r--r--source/blender/radiosity/intern/source/Makefile55
-rw-r--r--source/blender/radiosity/intern/source/raddisplay.c477
-rw-r--r--source/blender/radiosity/intern/source/radfactors.c939
-rw-r--r--source/blender/radiosity/intern/source/radio.c390
-rw-r--r--source/blender/radiosity/intern/source/radnode.c1103
-rw-r--r--source/blender/radiosity/intern/source/radpostprocess.c824
-rw-r--r--source/blender/radiosity/intern/source/radpreprocess.c828
-rw-r--r--source/blender/radiosity/intern/source/radrender.c530
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h3
-rw-r--r--source/blender/render/intern/source/convertblender.c10
-rw-r--r--source/blender/render/intern/source/pipeline.c19
-rw-r--r--source/blender/render/intern/source/zbuf.c108
-rw-r--r--source/blender/windowmanager/WM_types.h31
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c5
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c311
75 files changed, 1873 insertions, 7260 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index a53b15673e2..a9e3d50211f 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -37,7 +37,6 @@ ADD_SUBDIRECTORY(imbuf/intern/cineon)
ADD_SUBDIRECTORY(gpu)
ADD_SUBDIRECTORY(makesdna)
ADD_SUBDIRECTORY(makesrna)
-ADD_SUBDIRECTORY(radiosity)
ADD_SUBDIRECTORY(readblenfile)
ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(blenfont)
diff --git a/source/blender/Makefile b/source/blender/Makefile
index 64eb1a2614b..31636f838c3 100644
--- a/source/blender/Makefile
+++ b/source/blender/Makefile
@@ -31,7 +31,7 @@
include nan_definitions.mk
DIRS = windowmanager editors blenloader readblenfile
-DIRS += avi imbuf render radiosity blenlib blenkernel blenpluginapi
+DIRS += avi imbuf render blenlib blenkernel blenpluginapi
DIRS += makesdna makesrna
DIRS += python nodes gpu
DIRS += blenfont
diff --git a/source/blender/SConscript b/source/blender/SConscript
index 691fbf9b494..a064850c170 100644
--- a/source/blender/SConscript
+++ b/source/blender/SConscript
@@ -13,7 +13,6 @@ SConscript(['avi/SConscript',
'imbuf/intern/cineon/SConscript',
'makesdna/SConscript',
'makesrna/SConscript',
- 'radiosity/SConscript',
'readblenfile/SConscript',
'render/SConscript',
'nodes/SConscript',
diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h
index 11dc1f41109..5c47eeabfe8 100644
--- a/source/blender/blenkernel/BKE_exotic.h
+++ b/source/blender/blenkernel/BKE_exotic.h
@@ -47,7 +47,6 @@ int BKE_read_exotic(struct Scene *scene, char *name);
void write_dxf(struct Scene *scene, char *str);
void write_vrml(struct Scene *scene, char *str);
-void write_videoscape(struct Scene *scene, char *str);
void write_stl(struct Scene *scene, char *str);
#endif
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 4efd9a7f8ba..0ecd71fc4a3 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -217,6 +217,7 @@ char *psys_menu_string(struct Object *ob, int for_sb);
struct ParticleSystem *psys_get_current(struct Object *ob);
short psys_get_current_num(struct Object *ob);
+struct Object *psys_find_object(struct Scene *scene, struct ParticleSystem *psys);
//struct ParticleSystem *psys_get(struct Object *ob, int index);
struct ParticleData *psys_get_selected_particle(struct ParticleSystem *psys, int *index);
struct ParticleKey *psys_get_selected_key(struct ParticleSystem *psys, int pa_index, int *key_index);
@@ -251,6 +252,7 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P
struct ParticleSettings *psys_new_settings(char *name, struct Main *main);
struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part);
+int psys_count_autocache(struct Scene *scene, struct ParticleSettings *part);
void psys_flush_particle_settings(struct Scene *scene, struct ParticleSettings *part, int recalc);
void make_local_particlesettings(struct ParticleSettings *part);
@@ -290,10 +292,13 @@ void psys_get_reactor_target(struct Object *ob, struct ParticleSystem *psys, str
void psys_init_effectors(struct Scene *scene, struct Object *obsrc, struct Group *group, struct ParticleSystem *psys);
void psys_end_effectors(struct ParticleSystem *psys);
+void psys_get_pointcache_start_end(struct Scene *scene, struct ParticleSystem *psys, int *sfra, int *efra);
+
void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* ----------- functions needed only inside particlesystem ------------ */
/* particle.c */
+void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, int velocity);
void psys_key_to_object(struct Object *ob, struct ParticleKey *key, float imat[][4]);
//void psys_key_to_geometry(struct DerivedMesh *dm, struct ParticleData *pa, struct ParticleKey *key);
//void psys_key_from_geometry(struct DerivedMesh *dm, struct ParticleData *pa, struct ParticleKey *key);
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 8ef3ff4d4b7..b79357edf36 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -31,6 +31,8 @@
#include "DNA_ID.h"
+#include "MEM_guardedalloc.h"
+
/* Point cache clearing option, for BKE_ptcache_id_clear, before
* and after are non inclusive (they wont remove the cfra) */
#define PTCACHE_CLEAR_ALL 0
@@ -42,6 +44,7 @@
#define PTCACHE_RESET_DEPSGRAPH 0
#define PTCACHE_RESET_BAKED 1
#define PTCACHE_RESET_OUTDATED 2
+#define PTCACHE_RESET_FREE 3
/* Add the blendfile name after blendcache_ */
#define PTCACHE_EXT ".bphys"
@@ -56,6 +59,11 @@
#define PTCACHE_TYPE_PARTICLES 1
#define PTCACHE_TYPE_CLOTH 2
+/* PTCache read return code */
+#define PTCACHE_READ_EXACT 1
+#define PTCACHE_READ_INTERPOLATED 2
+#define PTCACHE_READ_OLD 3
+
/* Structs */
struct Object;
struct Scene;
@@ -80,6 +88,41 @@ typedef struct PTCacheID {
struct PointCache *cache;
} PTCacheID;
+typedef struct PTCacheWriter {
+ struct PTCacheID *pid;
+ int cfra;
+ int totelem;
+
+ float *(*elem_ptr)(int index, void *calldata);
+ void *calldata;
+} PTCacheWriter;
+
+typedef struct PTCacheReader {
+ struct Scene *scene;
+ struct PTCacheID *pid;
+ float cfra;
+ int totelem;
+
+ void (*set_elem)(int index, void *calldata, float *data);
+ void (*interpolate_elem)(int index, void *calldata, float frs_sec, float cfra, int cfra1, int cfra2, float *data1, float *data2);
+ void *calldata;
+
+ int allow_interpolate;
+ int allow_old;
+ int *old_frame;
+} PTCacheReader;
+
+typedef struct PTCacheBaker {
+ struct Scene *scene;
+ int bake;
+ int render;
+ struct PTCacheID *pid;
+ int (*break_test)(void *data);
+ void *break_data;
+ void (*progressbar)(void *data, int num);
+ void *progresscontext;
+} PTCacheBaker;
+
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb);
void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
@@ -93,9 +136,9 @@ void BKE_ptcache_remove(void);
/* ID specific functions */
void BKE_ptcache_id_clear(PTCacheID *id, int mode, int cfra);
int BKE_ptcache_id_exist(PTCacheID *id, int cfra);
-int BKE_ptcache_id_reset(PTCacheID *id, int mode);
+int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *id, int mode);
void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale);
-int BKE_ptcache_object_reset(struct Object *ob, int mode);
+int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode);
/* File reading/writing */
PTCacheFile *BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra);
@@ -103,6 +146,10 @@ void BKE_ptcache_file_close(PTCacheFile *pf);
int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot);
int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot);
+/* General cache reading/writing */
+int BKE_ptcache_read_cache(PTCacheReader *reader);
+int BKE_ptcache_write_cache(PTCacheWriter *writer);
+
/* Continue physics */
void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable);
int BKE_ptcache_get_continue_physics(void);
@@ -112,4 +159,9 @@ struct PointCache *BKE_ptcache_add(void);
void BKE_ptcache_free(struct PointCache *cache);
struct PointCache *BKE_ptcache_copy(struct PointCache *cache);
+/* Baking */
+void BKE_ptcache_autocache_all(struct Scene *scene);
+void BKE_ptcache_make_cache(struct PTCacheBaker* baker);
+void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid);
+
#endif
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 0bed2c095e2..f6c305b202d 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -131,7 +131,7 @@
#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
/* this weirdo pops up in two places ... */
-#if !defined(WIN32) && !defined(__BeOS)
+#if !defined(WIN32)
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -149,12 +149,6 @@
#define ID_NEW(a) if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid
#define FORM MAKE_ID('F','O','R','M')
-#define DDG1 MAKE_ID('3','D','G','1')
-#define DDG2 MAKE_ID('3','D','G','2')
-#define DDG3 MAKE_ID('3','D','G','3')
-#define DDG4 MAKE_ID('3','D','G','4')
-
-#define GOUR MAKE_ID('G','O','U','R')
#define BLEN MAKE_ID('B','L','E','N')
#define DER_ MAKE_ID('D','E','R','_')
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 5fc7d18689d..d3d21018c1c 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -221,7 +221,6 @@ static void clear_global(void)
{
// extern short winqueue_break; /* screen.c */
-// XXX freeAllRad();
fastshade_free_render(); /* lamps hang otherwise */
free_main(G.main); /* free all lib data */
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 8bb34bde122..b57b8b7a6da 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -1831,7 +1831,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
}
/* node was checked to have lasttime != curtime , and is of type ID_OB */
-static void flush_pointcache_reset(DagNode *node, int curtime, int reset)
+static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset)
{
DagAdjList *itA;
Object *ob;
@@ -1844,13 +1844,13 @@ static void flush_pointcache_reset(DagNode *node, int curtime, int reset)
ob= (Object*)(node->ob);
if(reset || (ob->recalc & OB_RECALC)) {
- if(BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH))
+ if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
- flush_pointcache_reset(itA->node, curtime, 1);
+ flush_pointcache_reset(scene, itA->node, curtime, 1);
}
else
- flush_pointcache_reset(itA->node, curtime, 0);
+ flush_pointcache_reset(scene, itA->node, curtime, 0);
}
}
}
@@ -1908,13 +1908,13 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
ob= (Object*)(itA->node->ob);
if(ob->recalc & OB_RECALC) {
- if(BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH))
+ if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
- flush_pointcache_reset(itA->node, lasttime, 1);
+ flush_pointcache_reset(sce, itA->node, lasttime, 1);
}
else
- flush_pointcache_reset(itA->node, lasttime, 0);
+ flush_pointcache_reset(sce, itA->node, lasttime, 0);
}
}
}
@@ -2132,7 +2132,7 @@ void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
if(ob==NULL || sce->theDag==NULL) return;
ob->recalc |= flag;
- BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH);
+ BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
/* all users of this ob->data should be checked */
/* BUT! displists for curves are still only on cu */
@@ -2147,7 +2147,7 @@ void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
for (obt=G.main->object.first; obt; obt= obt->id.next) {
if (obt != ob && obt->data==ob->data) {
obt->recalc |= OB_RECALC_DATA;
- BKE_ptcache_object_reset(obt, PTCACHE_RESET_DEPSGRAPH);
+ BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
}
}
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index 929d3f942dc..f15e1c24949 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -27,47 +27,7 @@
*
* - Blender Foundation
*
- * ***** END GPL LICENSE BLOCK *****
- *
- * eigen videoscape formaat:
- *
- *
- * lamp:
- * 3DG2
- aantal_lampen
-
- type
- spsi spbl
- r, g, b, energy
- locx, locy, locz
- vecx, vecy, vecz
-
-
- curve / nurbs:
- 3DG3
- 5 of 11 (curve of surf)
- aantal_nurbs
- extr1 extr2
-
- mat[0][0] mat[0][1] mat[0][2] mat[0][3]
- mat[1][0] mat[1][1] mat[1][2] mat[1][3]
- ...
-
- type
- pntsu, pntsv
- resolu, resolv
- orderu, orderv
- flagu, flagv
-
- (als type==nurb) x y z w
- x y z w
- ...
- (als type==bez) xyz xyz xyz h1 h2 h3
- xyz xyz xyz h1 h2 h3
- ...
- *
- *
- */
+ * ***** END GPL LICENSE BLOCK *****/
#include <ctype.h> /* isdigit, isspace */
@@ -482,385 +442,6 @@ static void read_stl_mesh_ascii(Scene *scene, char *str)
#undef STLREADLINE
#undef STLREADVERT
-static void read_videoscape_mesh(Scene *scene, char *str)
-{
- Object *ob;
- Mesh *me;
- MVert *mvert;
- MFace *mface;
- Material *ma;
- FILE *fp;
- float *vertdata, *vd, min[3], max[3], cent[3], ftemp;
- unsigned int color[32], col;
- int totcol, a, b, verts, tottria=0, totquad=0, totedge=0, poly, nr0, nr, first;
- int end;
- char s[50];
-
- fp= fopen(str, "rb");
- if(fp==NULL) {
- //XXX error("Can't read file");
- return;
- }
-
- fscanf(fp, "%40s", s);
-
- fscanf(fp, "%d\n", &verts);
- if(verts<=0) {
- fclose(fp);
- //XXX error("Read error");
- return;
- }
-
- if(verts>MESH_MAX_VERTS) {
- //XXX error("too many vertices");
- fclose(fp);
- return;
- }
-
- INIT_MINMAX(min, max);
- vd= vertdata= MEM_mallocN(sizeof(float)*3*verts, "videoscapelezer");
-
- for(a=0; a<verts; a++) {
- fscanf(fp, "%f %f %f", vd, vd+1, vd+2);
- DO_MINMAX(vd, min, max);
- vd+=3;
- }
-
- /* count faces and colors */
- for(a=0; a<32; a++) color[a]= 0;
- totcol= 0;
- end= 1;
- while(end>0) {
- end= fscanf(fp,"%d", &poly);
- if(end<=0) break;
-
- if(poly==3) tottria++;
- else if(poly==4) totquad++;
- else totedge+= poly;
-
- for(a=0;a<poly;a++) {
- end= fscanf(fp,"%d", &nr);
- if(end<=0) break;
- }
- if(end<=0) break;
-
- end= fscanf(fp,"%i\n", &col);
- col &= 0xF0F0F0;
- for(a=0; a<totcol; a++) {
- if(color[a]==col) break;
- }
- if(a>=totcol && totcol<32) {
- color[totcol]= col;
- totcol++;
- }
- }
-
- /* new object */
- ob= add_object(scene, OB_MESH);
- me= ob->data;
- me->totvert= verts;
- me->totface= totedge+tottria+totquad;
-
- me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC,
- NULL, me->totvert);
- me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC,
- NULL, me->totface);
-
- /* colors */
- if(totcol) {
- ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat");
- me->mat= MEM_callocN(sizeof(void *)*totcol, "me->mat");
- me->totcol= totcol;
- ob->totcol= (unsigned char) me->totcol;
- ob->actcol= 1;
- }
-
- /* materials */
- for(a=0; a<totcol; a++) {
- ma= G.main->mat.first;
- while(ma) {
- if(ma->mtex[0]==0) {
- col= rgb_to_cpack(ma->r, ma->g, ma->b);
- if(color[a]==col) {
- me->mat[a]= ma;
- ma->id.us++;
- break;
- }
- }
- ma= ma->id.next;
- }
- if(ma==0) {
- ma= add_material("ext");
- me->mat[a]= ma;
- cpack_to_rgb(color[a], cent, cent+1, cent+2);
- ma->r= cent[0];
- ma->g= cent[1];
- ma->b= cent[2];
- automatname(ma);
- }
- }
-
- /* verts */
-
- cent[0]= (min[0]+max[0])/2.0f;
- cent[1]= (min[1]+max[1])/2.0f;
- cent[2]= (min[2]+max[2])/2.0f;
- VECCOPY(ob->loc, cent);
-
- a= me->totvert;
- vd= vertdata;
- mvert= me->mvert;
- while(a--) {
- VecSubf(mvert->co, vd, cent);
- mvert++;
- vd+= 3;
- }
-
- /* faces */
- if(me->totface) {
- rewind(fp);
-
- fscanf(fp, "%40s", s);
- fscanf(fp, "%d\n", &verts);
- /* fake read */
- for(a=0;a<verts;a++) {
- fscanf(fp, "%f %f %f", &ftemp, &ftemp, &ftemp);
- }
-
- a= me->totface;
- mface= me->mface;
- while(a--) {
- end= fscanf(fp,"%d", &poly);
- if(end<=0) break;
-
- if(poly==3 || poly==4) {
- fscanf(fp,"%d", &nr);
- mface->v1= MIN2(nr, me->totvert-1);
- fscanf(fp,"%d", &nr);
- mface->v2= MIN2(nr, me->totvert-1);
- fscanf(fp,"%d", &nr);
- mface->v3= MIN2(nr, me->totvert-1);
- if(poly==4) {
- if( fscanf(fp,"%d", &nr) <=0 ) break;
- mface->v4= MIN2(nr, me->totvert-1);
- }
-
- test_index_face(mface, NULL, 0, poly);
-
- mface++;
- }
- else {
- if( fscanf(fp,"%d", &nr0) <=0) break;
- first= nr0;
- for(b=1; b<poly; b++) {
- end= fscanf(fp,"%d", &nr);
- if(end<=0) break;
- nr= MIN2(nr, me->totvert-1);
- mface->v1= nr;
- mface->v2= nr0;
- nr0= nr;
- mface++;
- a--;
- }
- mface->v1= first;
- mface->v2= nr;
- mface++;
- if(end<=0) break;
- }
- end= fscanf(fp,"%i", &col);
- col &= 0xF0F0F0;
- if(end<=0) break;
-
- for(b=0; b<totcol; b++) {
- if(color[b]==col) {
- (mface-1)->mat_nr= b;
- break;
- }
- }
- }
- }
-
- fclose(fp);
- MEM_freeN(vertdata);
-
- mesh_add_normals_flags(me);
- make_edges(me, 0);
-
- //XXX waitcursor(1);
-}
-
-static void read_videoscape_lamp(Scene *scene, char *str)
-{
- Object *ob;
- Lamp *la;
- FILE *fp;
- float vec[3], q1[4];
- int tot, val;
- char s[50];
-
- fp= fopen(str, "rb");
- if(fp==NULL) {
- //XXX error("Can't read file");
- return;
- }
-
- fscanf(fp, "%40s", s);
- fscanf(fp, "%d\n", &tot);
-
- while(tot--) {
- ob= add_object(scene, OB_LAMP);
- la= ob->data;
-
- fscanf(fp, "%d\n", &val);
- la->type= val;
- if(la->type==1) la->type= LA_SPOT;
- else if(la->type==2) la->type= LA_SUN;
-
- fscanf(fp, "%f %f\n", &la->spotsize, &la->spotblend);
-
- fscanf(fp, "%f %f %f %f\n", &la->r, &la->g, &la->b, &la->energy);
-
- fscanf(fp, "%f %f %f\n", ob->loc, ob->loc+1, ob->loc+2);
- val= fscanf(fp, "%f %f %f\n", vec, vec+1, vec+2);
- vectoquat(vec, 5, 2, q1);
- QuatToEul(q1, ob->rot);
-
- if(val<=0) break;
-
- }
- fclose(fp);
-}
-
-static void read_videoscape_nurbs(Scene *scene, char *str)
-{
- Object *ob;
- Curve *cu;
- Nurb *nu;
- BezTriple *bezt;
- BPoint *bp;
- FILE *fp;
- float tmat[4][4], omat[3][3], imat[3][3], mat[3][3];
- int a, tot, type, val;
- char s[50];
-
- fp= fopen(str, "rb");
- if(fp==NULL) {
- //XXX error("Can't read file");
- return;
- }
-
- fscanf(fp, "%40s", s);
- fscanf(fp, "%d\n", &type);
-
- if(type==5) ob= add_object(scene, OB_SURF);
- else ob= add_object(scene, OB_CURVE);
- cu= ob->data;
-
- fscanf(fp, "%d\n", &tot);
- fscanf(fp, "%d %d\n", &type, &val);
-
- cu->ext1= 0.002f*type;
- cu->ext2= 0.002f*val;
-
- for(a=0; a<4; a++) fscanf(fp, "%e %e %e %e\n", tmat[a], tmat[a]+1, tmat[a]+2, tmat[a]+3);
-
- VECCOPY(ob->loc, tmat[3]);
-
- Mat3CpyMat4(omat, tmat);
- Mat3ToEul(omat, ob->rot);
- EulToMat3(ob->rot, mat);
- Mat3Inv(imat, mat);
- Mat3MulMat3((float ( * )[3])tmat, imat, omat);
-
- while(tot--) {
- nu= (Nurb*)MEM_callocN(sizeof(Nurb),"nu from exotic");
- BLI_addtail(&cu->nurb, nu);
-
- fscanf(fp, "%d\n", &type);
- nu->type= type;
-
- fscanf(fp, "%d %d\n", &type, &val);
- nu->pntsu= type; nu->pntsv= val;
- fscanf(fp, "%d %d\n", &type, &val);
- nu->resolu= type; nu->resolv= val;
- fscanf(fp, "%d %d\n", &type, &val);
- nu->orderu= type; nu->orderv= val;
- fscanf(fp, "%d %d\n", &type, &val);
- nu->flagu= type; nu->flagv= val;
-
- if( (nu->type & 7)==CU_BEZIER) {
- a= nu->pntsu;
- nu->bezt= bezt= MEM_callocN(a*sizeof(BezTriple), "bezt from exotic");
- while(a--) {
- fscanf(fp, "%f %f %f ", bezt->vec[0], bezt->vec[0]+1, bezt->vec[0]+2);
- Mat4MulVecfl(tmat, bezt->vec[0]);
- fscanf(fp, "%f %f %f ", bezt->vec[1], bezt->vec[1]+1, bezt->vec[1]+2);
- Mat4MulVecfl(tmat, bezt->vec[1]);
- fscanf(fp, "%f %f %f ", bezt->vec[2], bezt->vec[2]+1, bezt->vec[2]+2);
- Mat4MulVecfl(tmat, bezt->vec[2]);
- fscanf(fp, "%d %d\n", &type, &val);
- bezt->h1= type;
- bezt->h2= val;
- bezt++;
- }
- }
- else {
- a= nu->pntsu*nu->pntsv;
- if(a) {
- nu->bp= bp= MEM_callocN(a*sizeof(BPoint), "bp from exotic");
- while(a--) {
- fscanf(fp, "%f %f %f %f\n", bp->vec, bp->vec+1, bp->vec+2, bp->vec+3);
- Mat4MulVecfl(tmat, bp->vec);
- bp++;
- }
-
- val= KNOTSU(nu);
- nu->knotsu= MEM_mallocN(sizeof(float)*val, "knots");
- for(a=0; a<val; a++) fscanf(fp, "%f\n", nu->knotsu+a);
-
- if(nu->pntsv>1) {
- val= KNOTSV(nu);
- nu->knotsv= MEM_mallocN(sizeof(float)*val, "knots");
- for(a=0; a<val; a++) fscanf(fp, "%f\n", nu->knotsv+a);
- }
- }
- else {
- BLI_remlink(&cu->nurb, nu);
- MEM_freeN(nu);
- }
- }
- }
- fclose(fp);
-}
-
-static void read_videoscape(Scene *scene, char *str)
-{
- int file, type;
- unsigned int val;
- unsigned short numlen;
- char name[FILE_MAXDIR+FILE_MAXFILE], head[FILE_MAXDIR+FILE_MAXFILE], tail[FILE_MAXFILE];
-
- strcpy(name, str);
-
- while( TRUE ) {
- file= open(name, O_BINARY|O_RDONLY);
- if(file<=0) break;
- else {
- read(file, &type, 4);
- close(file);
-
- if(type==DDG1) read_videoscape_mesh(scene, name);
- else if(type==DDG2) read_videoscape_lamp(scene, name);
- else if(type==DDG3) read_videoscape_nurbs(scene, name);
- }
-
- val = BLI_stringdec(name, head, tail, &numlen);
- BLI_stringenc(name, head, tail, numlen, val + 1);
-
- }
-}
-
-
/* ***************** INVENTOR ******************* */
@@ -2204,16 +1785,7 @@ int BKE_read_exotic(Scene *scene, char *name)
if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) {
//XXX waitcursor(1);
-
- if(ELEM4(*s0, DDG1, DDG2, DDG3, DDG4)) {
- if(0) { // XXX obedit) {
- //XXX error("Unable to perform function in EditMode");
- } else {
- read_videoscape(scene, name);
- retval = 1;
- }
- }
- else if(strncmp(str, "#Inventor V1.0", 14)==0) {
+ if(strncmp(str, "#Inventor V1.0", 14)==0) {
if( strncmp(str+15, "ascii", 5)==0) {
read_inventor(scene, name, &lbase);
displist_to_objects(scene, &lbase);
@@ -2385,167 +1957,6 @@ void write_stl(Scene *scene, char *str)
//XXX waitcursor(0);
}
-static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
-{
- Mesh *me= ob->data;
- EditMesh *em = BKE_mesh_get_editmesh(me);
- Material *ma;
- MFace *mface;
- FILE *fp;
- EditVert *eve;
- EditFace *evl;
- unsigned int kleur[32];
- float co[3];
- int a;
- intptr_t tot;
- char *cp;
-
- if(ob && ob->type==OB_MESH);
- else {
- return;
- }
-
- kleur[0]= 0x00C0C0C0;
-
- cp= (char *)kleur;
- for(a=0; a<ob->totcol; a++, cp+=4) {
-
- ma= give_current_material(ob, a+1);
- if(ma) {
- cp[0]= (unsigned char) (255.0*ma->emit);
- cp[1]= (unsigned char) (255.0*ma->b);
- cp[2]= (unsigned char) (255.0*ma->g);
- cp[3]= (unsigned char) (255.0*ma->r);
- if(ENDIAN_ORDER==L_ENDIAN) SWITCH_INT(kleur[a]);
- }
- else kleur[a]= 0x00C0C0C0;
-
- if(a>30) break;
- }
-
- fp= fopen(str, "wb");
- if(fp==NULL) return;
-
- fprintf(fp,"3DG1\n");
-
- if(em) {
-
- fprintf(fp, "%d\n", em->totvert);
-
- tot= 0;
- eve= em->verts.first;
- while(eve) {
- VECCOPY(co, eve->co);
- Mat4MulVecfl(ob->obmat, co);
- fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] );
- eve->tmp.l = tot;
- tot++;
- eve= eve->next;
- }
- evl= em->faces.first;
- while(evl) {
-
- if(evl->v4==0) {
- fprintf(fp, "3 %ld %ld %ld 0x%x\n",
- (intptr_t) evl->v1->tmp.l,
- (intptr_t) evl->v2->tmp.l,
- (intptr_t) evl->v3->tmp.l,
- kleur[evl->mat_nr]);
- }
- else {
- fprintf(fp, "4 %ld %ld %ld %ld 0x%x\n",
- (intptr_t) evl->v1->tmp.l,
- (intptr_t) evl->v2->tmp.l,
- (intptr_t) evl->v3->tmp.l,
- (intptr_t) evl->v4->tmp.l,
- kleur[evl->mat_nr]);
- }
- evl= evl->next;
- }
- }
- else {
- DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
-
- me= ob->data;
-
- fprintf(fp, "%d\n", me->totvert);
-
- mface= me->mface;
- for(a=0; a<me->totvert; a++) {
- dm->getVertCo(dm, a, co);
- Mat4MulVecfl(ob->obmat, co);
- fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] );
- }
- for(a=0; a<me->totface; a++, mface++) {
- if(mface->v4==0) {
- fprintf(fp, "3 %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, kleur[(int)mface->mat_nr]);
- }
- else {
- fprintf(fp, "4 %d %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, mface->v4, kleur[(int)mface->mat_nr]);
- }
- }
-
- dm->release(dm);
- }
-
- fclose(fp);
-
- if (em) BKE_mesh_end_editmesh(me, em);
-
-}
-
-
-void write_videoscape(Scene *scene, char *str)
-{
- Base *base;
- int file, val, lampdone=0;
- unsigned short numlen;
- char head[FILE_MAXFILE], tail[FILE_MAXFILE];
-
- if(BLI_testextensie(str,".trace")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
- if(BLI_testextensie(str,".obj")==0) strcat(str, ".obj");
-
- file= open(str,O_BINARY|O_RDONLY);
- close(file);
- //XXX saveover()
- // if(file>-1) if(!during_script() && saveover(str)==0) return;
-
- strcpy(temp_dir, str);
-
- base= scene->base.first;
- while(base) {
- if((base->flag & SELECT) && (base->lay & scene->lay)) {
- if(base->object->type==OB_MESH) {
- write_videoscape_mesh(scene, base->object, str);
- val = BLI_stringdec(str, head, tail, &numlen);
- BLI_stringenc(str, head, tail, numlen, val + 1);
- }
- else if(base->object->type==OB_CURVE || base->object->type==OB_SURF) {
- /* write_videoscape_nurbs(base->object, str); */
- /* val = stringdec(str, head, tail, &numlen); */
- /* stringenc(str, head, tail, numlen, val + 1); */
- }
- else if(lampdone==0 && base->object->type==OB_LAMP) {
- /* lampdone= 1; */
- /* write_videoscape_lamps(str); */
- /* val = stringdec(str, head, tail, &numlen); */
- /* stringenc(str, head, tail, numlen, val + 1); */
- }
- }
- base= base->next;
- }
-
-
- /* remove when higher numbers exist */
- while(remove(str)==0) {
-
- val = BLI_stringdec(str, head, tail, &numlen);
- BLI_stringenc(str, head, tail, numlen, val + 1);
- }
-}
-
/* ******************************* WRITE VRML ***************************** */
static void replace_chars(char *str1, char *str2)
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index b1387281cf5..5def910ddef 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -1270,8 +1270,10 @@ void multires_free(Multires *mr)
if(lvl) {
CustomData_free(&mr->vdata, lvl->totvert);
CustomData_free(&mr->fdata, lvl->totface);
- MEM_freeN(mr->edge_flags);
- MEM_freeN(mr->edge_creases);
+ if(mr->edge_flags)
+ MEM_freeN(mr->edge_flags);
+ if(mr->edge_creases)
+ MEM_freeN(mr->edge_creases);
}
while(lvl) {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 34e69b2d736..5b3720cd6b0 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -222,6 +222,45 @@ short psys_get_current_num(Object *ob)
return i;
}
+Object *psys_find_object(Scene *scene, ParticleSystem *psys)
+{
+ Base *base = scene->base.first;
+ ParticleSystem *tpsys;
+
+ for(base = scene->base.first; base; base = base->next) {
+ for(tpsys = base->object->particlesystem.first; psys; psys=psys->next) {
+ if(tpsys == psys)
+ return base->object;
+ }
+ }
+
+ return NULL;
+}
+int psys_count_autocache(Scene *scene, ParticleSettings *part)
+{
+ Base *base = scene->base.first;
+ ParticleSystem *psys;
+ PTCacheID pid;
+ int autocache_count= 0;
+
+ for(base = scene->base.first; base; base = base->next) {
+ for(psys = base->object->particlesystem.first; psys; psys=psys->next) {
+ if(part && psys->part != part)
+ continue;
+
+ BKE_ptcache_id_from_particles(&pid, base->object, psys);
+
+ if((psys->pointcache->flag & PTCACHE_BAKED)
+ || (psys->pointcache->flag & PTCACHE_AUTOCACHE)==0)
+ continue;
+
+ if((psys->pointcache->flag & PTCACHE_OUTDATED)
+ || BKE_ptcache_id_exist(&pid, CFRA)==0)
+ autocache_count++;
+ }
+ }
+ return autocache_count;
+}
/* change object's active particle system */
void psys_change_act(void *ob_v, void *act_v)
{
@@ -864,7 +903,7 @@ static void weighted_particle_vector(float *v1, float *v2, float *v3, float *v4,
vec[1]= weights[0]*v1[1] + weights[1]*v2[1] + weights[2]*v3[1] + weights[3]*v4[1];
vec[2]= weights[0]*v1[2] + weights[1]*v2[2] + weights[2]*v3[2] + weights[3]*v4[2];
}
-static void interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity)
+void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity)
{
float t[4];
@@ -2569,7 +2608,7 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
}
/* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/
- interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
+ psys_interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
: ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL)
,keys, keytime, &result, 0);
@@ -3062,7 +3101,6 @@ void make_local_particlesettings(ParticleSettings *part)
}
}
}
-
void psys_flush_particle_settings(Scene *scene, ParticleSettings *part, int recalc)
{
Base *base = scene->base.first;
@@ -3495,7 +3533,7 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
QuatInterpol(state->rot,keys[1].rot,keys[2].rot,keytime);
}
- interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
+ psys_interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
: ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL)
,keys, keytime, state, 1);
@@ -3776,7 +3814,7 @@ int psys_get_particle_state(struct Scene *scene, Object *ob, ParticleSystem *psy
VecMulf(keys[1].vel, dfra / frs_sec);
VecMulf(keys[2].vel, dfra / frs_sec);
- interpolate_particle(-1, keys, keytime, state, 1);
+ psys_interpolate_particle(-1, keys, keytime, state, 1);
/* convert back to real velocity */
VecMulf(state->vel, frs_sec / dfra);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 52f13eeadb8..fc6413849d1 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -104,7 +104,8 @@ static int get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
- if(psys->renderdata || (part->child_nbr && part->childtype))
+ if(psys->renderdata || (part->child_nbr && part->childtype)
+ || (psys->pointcache->flag & PTCACHE_BAKING))
return 100;
if(part->phystype==PART_PHYS_KEYED){
@@ -2195,57 +2196,80 @@ void psys_get_reactor_target(Object *ob, ParticleSystem *psys, Object **target_o
/************************************************/
/* Point Cache */
/************************************************/
-
-static void write_particles_to_cache(Object *ob, ParticleSystem *psys, int cfra)
+void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
{
- PTCacheID pid;
- PTCacheFile *pf;
- ParticleData *pa;
- int i, totpart= psys->totpart;
+ ParticleSettings *part = psys->part;
- if(totpart == 0)
- return;
+ *sfra = MAX2(1, (int)part->sta);
+ *efra = MIN2((int)(part->end + part->lifetime + 1.0), scene->r.efra);
+}
+static float *particle_state_ptr(int index, ParticleSystem *psys)
+{
+ return (float *)(&(psys->particles+index)->state);
+}
+static void particle_read_state(int index, ParticleSystem *psys, float *data)
+{
+ ParticleData *pa = psys->particles + index;
+ ParticleKey *key = (ParticleKey *)data;
- BKE_ptcache_id_from_particles(&pid, ob, psys);
- pf= BKE_ptcache_file_open(&pid, PTCACHE_FILE_WRITE, cfra);
- if(!pf)
- return;
+ if(key->time > pa->state.time)
+ copy_particle_key(&pa->prev_state, &pa->state, 1);
- /* assuming struct consists of tightly packed floats */
- for(i=0, pa=psys->particles; i<totpart; i++, pa++)
- BKE_ptcache_file_write_floats(pf, (float*)&pa->state, sizeof(ParticleKey)/sizeof(float));
-
- BKE_ptcache_file_close(pf);
+ copy_particle_key(&pa->state, key, 1);
}
+static void particle_cache_interpolate(int index, ParticleSystem *psys, float frs_sec, float cfra, int cfra1, int cfra2, float *data1, float *data2)
+{
+ ParticleData *pa = psys->particles + index;
+ ParticleKey keys[4];
+ float dfra;
+
+ keys[1] = *((ParticleKey*)data1);
+ keys[2] = *((ParticleKey*)data2);
+
+ dfra = keys[2].time - keys[1].time;
-static int get_particles_from_cache(Object *ob, ParticleSystem *psys, int cfra)
+ VecMulf(keys[1].vel, dfra / frs_sec);
+ VecMulf(keys[2].vel, dfra / frs_sec);
+
+ psys_interpolate_particle(-1, keys, (keys[1].time - cfra) / dfra, &pa->state, 1);
+
+ VecMulf(pa->state.vel, frs_sec / dfra);
+}
+static void write_particles_to_cache(Object *ob, ParticleSystem *psys, int cfra)
{
+ PTCacheWriter writer;
PTCacheID pid;
- PTCacheFile *pf;
- ParticleData *pa;
- int i, totpart= psys->totpart;
-
- if(totpart == 0)
- return 0;
BKE_ptcache_id_from_particles(&pid, ob, psys);
- pf= BKE_ptcache_file_open(&pid, PTCACHE_FILE_READ, cfra);
- if(!pf)
- return 0;
- /* assuming struct consists of tightly packed floats */
- for(i=0, pa=psys->particles; i<totpart; i++, pa++) {
- if(cfra!=pa->state.time)
- copy_particle_key(&pa->prev_state,&pa->state,1);
- if(!BKE_ptcache_file_read_floats(pf, (float*)&pa->state, sizeof(ParticleKey)/sizeof(float))) {
- BKE_ptcache_file_close(pf);
- return 0;
- }
- }
+ writer.calldata = psys;
+ writer.cfra = cfra;
+ writer.elem_ptr = particle_state_ptr;
+ writer.pid = &pid;
+ writer.totelem = psys->totpart;
- BKE_ptcache_file_close(pf);
+ BKE_ptcache_write_cache(&writer);
+}
- return 1;
+static int get_particles_from_cache(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int allow_interpolate, int allow_old, int *old_frame)
+{
+ PTCacheReader reader;
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+
+ reader.allow_interpolate = allow_interpolate;
+ reader.allow_old = allow_old;
+ reader.calldata = psys;
+ reader.cfra = cfra;
+ reader.interpolate_elem = particle_cache_interpolate;
+ reader.old_frame = old_frame;
+ reader.pid = &pid;
+ reader.scene = scene;
+ reader.set_elem = particle_read_state;
+ reader.totelem = psys->totpart;
+
+ return BKE_ptcache_read_cache(&reader);
}
/************************************************/
@@ -4085,7 +4109,7 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
/* main loop: calculate physics for all particles */
for(p=0, pa=psys->particles; p<totpart; p++,pa++){
- if(pa->flag & PARS_UNEXIST) continue;
+ if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue;
copy_particle_key(&pa->prev_state,&pa->state,1);
@@ -4110,25 +4134,26 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
if(pa->alive==PARS_UNBORN
|| pa->alive==PARS_KILLED
|| ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED)
- || birthtime >= cfra){
+ || birthtime >= psys->cfra){
reset_particle(scene, pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
}
pa_dfra = dfra;
pa_dtime = dtime;
- if(birthtime <= cfra && birthtime >= psys->cfra){
+
+ if(dietime <= cfra && psys->cfra < dietime){
+ /* particle dies some time between this and last step */
+ pa_dfra = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra);
+ pa_dtime = pa_dfra * timestep;
+ pa->alive = PARS_DYING;
+ }
+ else if(birthtime <= cfra && birthtime >= psys->cfra){
/* particle is born some time between this and last step*/
pa->alive = PARS_ALIVE;
pa_dfra = cfra - birthtime;
pa_dtime = pa_dfra*timestep;
}
- else if(dietime <= cfra && psys->cfra < dietime){
- /* particle dies some time between this and last step */
- pa_dfra = dietime - psys->cfra;
- pa_dtime = pa_dfra * timestep;
- pa->alive = PARS_DYING;
- }
else if(dietime < cfra){
/* nothing to be done when particle is dead */
}
@@ -4520,7 +4545,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
int totpart, oldtotpart, totchild, oldtotchild, p;
float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0;
int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0;
- int framenr, framedelta, startframe, endframe;
+ int framenr, framedelta, startframe, endframe, old_framenr;
part= psys->part;
cache= psys->pointcache;
@@ -4528,6 +4553,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
framenr= (int)scene->r.cfra;
framedelta= framenr - cache->simframe;
+ /* set suitable cache range automatically */
+ if((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0)
+ psys_get_pointcache_start_end(scene, psys, &cache->startframe, &cache->endframe);
+
BKE_ptcache_id_from_particles(&pid, ob, psys);
BKE_ptcache_id_time(&pid, scene, 0.0f, &startframe, &endframe, NULL);
@@ -4600,9 +4629,13 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
if(init) {
if(distr) {
- if(alloc)
+ if(alloc) {
realloc_particles(ob, psys, totpart);
+ if(usecache)
+ BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
+ }
+
distribute_particles(scene, ob, psys, part->from);
if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE))
@@ -4616,9 +4649,11 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
free_keyed_keys(psys);
initialize_all_particles(ob, psys, psmd);
+
- if(alloc)
+ if(alloc) {
reset_all_particles(scene, ob, psys, psmd, 0.0, cfra, oldtotpart);
+ }
}
/* flag for possible explode modifiers after this system */
@@ -4627,25 +4662,47 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
/* try to read from the cache */
if(usecache) {
- if(get_particles_from_cache(ob, psys, framenr)) {
- if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
- psys_count_keyed_targets(ob,psys);
- set_keyed_keys(scene, ob, psys);
- }
+ int result = get_particles_from_cache(scene, ob, psys, (float)framenr, 0, 1, &old_framenr);
+
+ if(result == PTCACHE_READ_EXACT) {
+ //if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
+ // psys_count_keyed_targets(ob,psys);
+ // set_keyed_keys(scene, ob, psys);
+ //}
cached_step(scene, ob, psmd, psys, cfra);
psys->cfra=cfra;
psys->recalc = 0;
- if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
- psys_update_path_cache(scene, ob, psmd, psys, framenr);
- }
+ //if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
+ // psys_update_path_cache(scene, ob, psmd, psys, framenr);
+ //}
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
+ if(cache->flag & PTCACHE_OUTDATED)
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
+
return;
}
+ else if((cache->flag & PTCACHE_AUTOCACHE)==0 && result==PTCACHE_READ_OLD) {
+ /* clear cache after current frame */
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
+
+ /* set old cfra */
+ psys->cfra = (float)old_framenr;
+
+ for(p=0, pa=psys->particles; p<totpart; p++, pa++) {
+ /* update alive status */
+ if(pa->time > psys->cfra)
+ pa->alive = PARS_UNBORN;
+ else if(pa->dietime <= psys->cfra)
+ pa->alive = PARS_DEAD;
+ else
+ pa->alive = PARS_ALIVE;
+ }
+ }
else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) {
psys_reset(psys, PSYS_RESET_CACHE_MISS);
psys->cfra=cfra;
@@ -4653,8 +4710,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
return;
}
- if(framenr != startframe && framedelta != 1) {
- psys_reset(psys, PSYS_RESET_CACHE_MISS);
+ if(framenr != startframe && framedelta != 1 && cache->flag & PTCACHE_AUTOCACHE) {
+ //psys_reset(psys, PSYS_RESET_CACHE_MISS);
+ /* make sure cache is recalculated */
+ BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_FRAME, (int)cfra);
psys->cfra = cfra;
psys->recalc = 0;
return;
@@ -4663,10 +4722,11 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
else {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
+ cache->last_exact= 0;
}
/* if on second frame, write cache for first frame */
- if(usecache && framenr == startframe+1)
+ if(usecache && psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
write_particles_to_cache(ob, psys, startframe);
if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED)
@@ -4768,8 +4828,7 @@ static void psys_to_softbody(Scene *scene, Object *ob, ParticleSystem *psys)
static int hair_needs_recalc(ParticleSystem *psys)
{
if((psys->flag & PSYS_EDITED)==0 &&
- ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_REDO)) {
- psys->recalc &= ~PSYS_RECALC_REDO;
+ ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET)) {
return 1;
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index b00755f7135..f59336518d7 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -51,9 +51,11 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
+#include "BKE_scene.h"
#include "BKE_softbody.h"
#include "BKE_utildefines.h"
+#include "BLI_blenlib.h"
/* needed for directory lookup */
#ifndef WIN32
@@ -213,21 +215,29 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho
filename[0] = '\0';
newname = filename;
- /*if (!G.relbase_valid) return 0; *//* save blend file before using pointcache */
+ if (!G.relbase_valid) return 0; /* save blend file before using disk pointcache */
/* start with temp dir */
if (do_path) {
len = ptcache_path(pid, filename);
newname += len;
}
- idname = (pid->ob->id.name+2);
- /* convert chars to hex so they are always a valid filename */
- while('\0' != *idname) {
- snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
- newname+=2;
- len += 2;
+ if(strcmp(pid->cache->name, "")==0) {
+ idname = (pid->ob->id.name+2);
+ /* convert chars to hex so they are always a valid filename */
+ while('\0' != *idname) {
+ snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
+ newname+=2;
+ len += 2;
+ }
}
-
+ else {
+ int temp = strlen(pid->cache->name);
+ strcpy(newname, pid->cache->name);
+ newname+=temp;
+ len += temp;
+ }
+
if (do_ext) {
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
len += 16;
@@ -247,7 +257,7 @@ PTCacheFile *BKE_ptcache_file_open(PTCacheID *pid, int mode, int cfra)
if(pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
return NULL;
- /*if (!G.relbase_valid) return NULL; *//* save blend file before using pointcache */
+ if (!G.relbase_valid) return NULL; /* save blend file before using disk pointcache */
BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
@@ -286,6 +296,323 @@ int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot)
return (fwrite(f, sizeof(float), tot, pf->fp) == tot);
}
+static int ptcache_pid_elemsize(PTCacheID *pid)
+{
+ if(pid->type==PTCACHE_TYPE_SOFTBODY)
+ return 0; // TODO
+ else if(pid->type==PTCACHE_TYPE_PARTICLES)
+ return sizeof(ParticleKey);
+ else if(pid->type==PTCACHE_TYPE_CLOTH)
+ return 0; // TODO
+
+ return 0;
+}
+static int ptcache_pid_totelem(PTCacheID *pid)
+{
+ if(pid->type==PTCACHE_TYPE_SOFTBODY)
+ return 0; // TODO
+ else if(pid->type==PTCACHE_TYPE_PARTICLES) {
+ ParticleSystem *psys = pid->data;
+ return psys->totpart;
+ }
+ else if(pid->type==PTCACHE_TYPE_CLOTH)
+ return 0; // TODO
+
+ return 0;
+}
+
+void ptcache_update_info(PTCacheID *pid)
+{
+ PointCache *cache = pid->cache;
+ int totframes = 0;
+
+ if(cache->flag & PTCACHE_DISK_CACHE) {
+ int cfra = cache->startframe;
+
+ for(; cfra<=cache->endframe; cfra++) {
+ if(BKE_ptcache_id_exist(pid, cfra))
+ totframes++;
+ }
+
+ sprintf(cache->info, "%i frames on disk.", totframes);
+ }
+ else {
+ PTCacheMem *pm = cache->mem_cache.first;
+ float framesize = 0.0f, bytes = 0.0f;
+ int mb;
+
+ if(pm)
+ framesize = (float)ptcache_pid_elemsize(pid) * (float)pm->totpoint;
+
+ for(; pm; pm=pm->next)
+ totframes++;
+
+ bytes = totframes * framesize;
+
+ mb = (bytes > 1024.0f * 1024.0f);
+
+ sprintf(cache->info, "%i frames in memory (%.1f %s).",
+ totframes,
+ bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
+ mb ? "Mb" : "kb");
+ }
+}
+/* reads cache from disk or memory */
+/* possible to get old or interpolated result */
+int BKE_ptcache_read_cache(PTCacheReader *reader)
+{
+ PTCacheID *pid = reader->pid;
+ PTCacheFile *pf=NULL, *pf2=NULL;
+ PTCacheMem *pm=NULL, *pm2=NULL;
+ int totelem = reader->totelem;
+ float cfra = reader->cfra;
+ int cfrai = (int)cfra;
+ int elemsize = ptcache_pid_elemsize(pid);
+ int i, incr = elemsize / sizeof(float);
+ float frs_sec = reader->scene->r.frs_sec;
+
+ if(totelem == 0)
+ return 0;
+
+ /* first check if we have the actual frame cached */
+ if(cfra == (float)cfrai) {
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
+ }
+ else {
+ pm = pid->cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ if(pm->frame == cfrai)
+ break;
+ }
+ }
+ }
+
+ /* if found, use exact frame */
+ if(pf || pm) {
+ float *data;
+
+ if(pm)
+ data = pm->data;
+ else
+ data = MEM_callocN(elemsize, "pointcache read data");
+
+ for(i=0; i<totelem; i++) {
+ if(pf) {
+ if(!BKE_ptcache_file_read_floats(pf, data, incr)) {
+ BKE_ptcache_file_close(pf);
+ MEM_freeN(data);
+ return 0;
+ }
+
+ reader->set_elem(i, reader->calldata, data);
+ }
+ else {
+ reader->set_elem(i, reader->calldata, data);
+ data += incr;
+ }
+ }
+
+ if(pf) {
+ BKE_ptcache_file_close(pf);
+ MEM_freeN(data);
+ }
+
+ return PTCACHE_READ_EXACT;
+ }
+ /* no exact cache frame found so try to find cached frames around cfra */
+ if(reader->allow_interpolate || reader->allow_old) {
+ int cfra1, cfra2;
+
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ pf=NULL;
+ while(cfrai > pid->cache->startframe && !pf) {
+ cfrai--;
+ pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
+ cfra1 = cfrai;
+ }
+
+ *(reader->old_frame) = cfrai;
+
+ cfrai = (int)cfra;
+ while(cfrai < pid->cache->endframe && !pf2) {
+ cfrai++;
+ pf2= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
+ cfra2 = cfrai;
+ }
+ }
+ else if(pid->cache->mem_cache.first){
+ pm = pid->cache->mem_cache.first;
+
+ while(pm->next && pm->next->frame < cfra)
+ pm= pm->next;
+
+ if(pm) {
+ *(reader->old_frame) = pm->frame;
+ cfra1 = pm->frame;
+ }
+
+ pm2 = pid->cache->mem_cache.last;
+
+ while(pm2->prev && pm2->frame > cfra)
+ pm2= pm2->prev;
+
+ if(pm2)
+ cfra2 = pm2->frame;
+ }
+
+ if(reader->allow_interpolate && ((pf && pf2) || (pm && pm2))) {
+ /* interpolate from nearest frames */
+ float *data1, *data2;
+
+ if(pm) {
+ data1 = pm->data;
+ data2 = pm2->data;
+ }
+ else {
+ data1 = MEM_callocN(elemsize, "pointcache read data1");
+ data2 = MEM_callocN(elemsize, "pointcache read data2");
+ }
+
+ for(i=0; i<totelem; i++) {
+ if(pf && pf2) {
+ if(!BKE_ptcache_file_read_floats(pf, data1, incr)) {
+ BKE_ptcache_file_close(pf);
+ BKE_ptcache_file_close(pf2);
+ MEM_freeN(data1);
+ MEM_freeN(data2);
+ return 0;
+ }
+ if(!BKE_ptcache_file_read_floats(pf2, data2, incr)) {
+ BKE_ptcache_file_close(pf);
+ BKE_ptcache_file_close(pf2);
+ MEM_freeN(data1);
+ MEM_freeN(data2);
+ return 0;
+ }
+ reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, cfra1, cfra2, data1, data2);
+ }
+ else {
+ reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, cfra1, cfra2, data1, data2);
+ data1 += incr;
+ data2 += incr;
+ }
+ }
+
+ if(pf) {
+ BKE_ptcache_file_close(pf);
+ BKE_ptcache_file_close(pf2);
+ MEM_freeN(data1);
+ MEM_freeN(data2);
+ }
+
+ return PTCACHE_READ_INTERPOLATED;
+ }
+ else if(reader->allow_old && (pf || pm)) {
+ /* use last valid cache frame */
+ float *data;
+
+ if(pm)
+ data = pm->data;
+ else
+ data = MEM_callocN(elemsize, "pointcache read data");
+
+ for(i=0; i<totelem; i++) {
+ if(pf) {
+ if(!BKE_ptcache_file_read_floats(pf, data, incr)) {
+ BKE_ptcache_file_close(pf);
+ if(pf2)
+ BKE_ptcache_file_close(pf2);
+ return 0;
+ }
+ reader->set_elem(i, reader->calldata, data);
+ }
+ else {
+ reader->set_elem(i, reader->calldata, data);
+ data += incr;
+ }
+ }
+
+ if(pf) {
+ BKE_ptcache_file_close(pf);
+ MEM_freeN(data);
+ }
+ if(pf2)
+ BKE_ptcache_file_close(pf2);
+
+ return PTCACHE_READ_OLD;
+ }
+ }
+
+ if(pf)
+ BKE_ptcache_file_close(pf);
+ if(pf2)
+ BKE_ptcache_file_close(pf2);
+
+ return 0;
+}
+/* writes cache to disk or memory */
+int BKE_ptcache_write_cache(PTCacheWriter *writer)
+{
+ PointCache *cache = writer->pid->cache;
+ PTCacheFile *pf= NULL;
+ int elemsize = ptcache_pid_elemsize(writer->pid);
+ int i, incr = elemsize / sizeof(float);
+
+ if(writer->totelem == 0 || writer->cfra <= 0)
+ return 0;
+
+ if(cache->flag & PTCACHE_DISK_CACHE) {
+ pf = BKE_ptcache_file_open(writer->pid, PTCACHE_FILE_WRITE, writer->cfra);
+ if(!pf)
+ return 0;
+
+ for(i=0; i<writer->totelem; i++)
+ BKE_ptcache_file_write_floats(pf, writer->elem_ptr(i, writer->calldata), incr);
+ }
+ else {
+ PTCacheMem *pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
+ PTCacheMem *pm2;
+ float *pmdata;
+
+ pm->data = MEM_callocN(elemsize * writer->totelem, "Pointcache mem data");
+ pmdata = pm->data;
+
+ for(i=0; i<writer->totelem; i++, pmdata+=incr)
+ memcpy(pmdata, writer->elem_ptr(i, writer->calldata), elemsize);
+
+ pm->frame = writer->cfra;
+ pm->totpoint = writer->totelem;
+
+ /* find add location */
+ pm2 = cache->mem_cache.first;
+ if(!pm2)
+ BLI_addtail(&cache->mem_cache, pm);
+ else if(pm2->frame == writer->cfra) {
+ /* overwrite same frame */
+ MEM_freeN(pm2->data);
+ pm2->data = pm->data;
+ MEM_freeN(pm);
+ }
+ else {
+ while(pm2->next && pm2->next->frame < writer->cfra)
+ pm2 = pm2->next;
+
+ BLI_insertlinkafter(&cache->mem_cache, pm2, pm);
+ }
+ }
+
+ if(writer->cfra - cache->last_exact == 1)
+ cache->last_exact = writer->cfra;
+
+ if(pf)
+ BKE_ptcache_file_close(pf);
+
+ ptcache_update_info(writer->pid);
+
+ return 1;
+}
/* youll need to close yourself after!
* mode - PTCACHE_CLEAR_ALL,
@@ -317,62 +644,116 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra)
case PTCACHE_CLEAR_ALL:
case PTCACHE_CLEAR_BEFORE:
case PTCACHE_CLEAR_AFTER:
- ptcache_path(pid, path);
-
- len = BKE_ptcache_id_filename(pid, filename, cfra, 0, 0); /* no path */
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
- if (mode == PTCACHE_CLEAR_ALL) {
- BLI_join_dirfile(path_full, path, de->d_name);
- BLI_delete(path_full, 0, 0);
- } else {
- /* read the number of the file */
- int frame, len2 = strlen(de->d_name);
- char num[7];
-
- if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
- BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
- frame = atoi(num);
-
- if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
- (mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ ptcache_path(pid, path);
+
+ len = BKE_ptcache_id_filename(pid, filename, cfra, 0, 0); /* no path */
+
+ dir = opendir(path);
+ if (dir==NULL)
+ return;
+
+ snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
+
+ while ((de = readdir(dir)) != NULL) {
+ if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
+ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
+ if (mode == PTCACHE_CLEAR_ALL) {
+ pid->cache->last_exact = 0;
+ BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_delete(path_full, 0, 0);
+ } else {
+ /* read the number of the file */
+ int frame, len2 = strlen(de->d_name);
+ char num[7];
+
+ if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
+ BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
+ frame = atoi(num);
- BLI_join_dirfile(path_full, path, de->d_name);
- BLI_delete(path_full, 0, 0);
+ if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
+ (mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
+
+ BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_delete(path_full, 0, 0);
+ }
}
}
}
}
}
+ closedir(dir);
+ }
+ else {
+ PTCacheMem *pm= pid->cache->mem_cache.first;
+ PTCacheMem *link= NULL;
+
+ if(mode == PTCACHE_CLEAR_ALL) {
+ pid->cache->last_exact = 0;
+ for(; pm; pm=pm->next)
+ MEM_freeN(pm->data);
+ BLI_freelistN(&pid->cache->mem_cache);
+ } else {
+ while(pm) {
+ if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
+ (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) {
+ link = pm;
+ pm = pm->next;
+ MEM_freeN(link->data);
+ BLI_freelinkN(&pid->cache->mem_cache, link);
+ }
+ else
+ pm = pm->next;
+ }
+ }
}
- closedir(dir);
break;
case PTCACHE_CLEAR_FRAME:
- len = BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); /* no path */
- BLI_delete(filename, 0, 0);
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if(BKE_ptcache_id_exist(pid, cfra)) {
+ BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); /* no path */
+ BLI_delete(filename, 0, 0);
+ }
+ }
+ else {
+ PTCacheMem *pm = pid->cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ if(pm->frame == cfra) {
+ MEM_freeN(pm->data);
+ BLI_freelinkN(&pid->cache->mem_cache, pm);
+ break;
+ }
+ }
+ }
break;
}
+
+ ptcache_update_info(pid);
}
int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
{
- char filename[MAX_PTCACHE_FILE];
-
if(!pid->cache)
return 0;
- BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ char filename[MAX_PTCACHE_FILE];
+
+ BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
- return BLI_exists(filename);
+ return BLI_exists(filename);
+ }
+ else {
+ PTCacheMem *pm = pid->cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ if(pm->frame==cfra)
+ return 1;
+ }
+ return 0;
+ }
}
void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
@@ -414,10 +795,10 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
}
}
-int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
+int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
{
PointCache *cache;
- int reset, clear;
+ int reset, clear, current, after;
if(!pid->cache)
return 0;
@@ -425,11 +806,20 @@ int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
cache= pid->cache;
reset= 0;
clear= 0;
+ current= 0;
+ after= 0;
if(mode == PTCACHE_RESET_DEPSGRAPH) {
if(!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
- reset= 1;
- clear= 1;
+ if(cache->flag & PTCACHE_AUTOCACHE) {
+ reset= 1;
+ clear= 1;
+ }
+ else {
+ current= 1;
+ after= 1;
+ cache->flag |= PTCACHE_OUTDATED;
+ }
}
else
cache->flag |= PTCACHE_OUTDATED;
@@ -449,10 +839,19 @@ int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
if(!(cache->flag & PTCACHE_BAKED))
clear= 1;
}
+ else if(mode == PTCACHE_RESET_FREE) {
+ if(!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
+ if((cache->flag & PTCACHE_AUTOCACHE)==0) {
+ current= 1;
+ after= 1;
+ }
+ }
+ }
if(reset) {
cache->flag &= ~(PTCACHE_OUTDATED|PTCACHE_SIMULATION_VALID);
cache->simframe= 0;
+ cache->last_exact= 0;
if(pid->type == PTCACHE_TYPE_CLOTH)
cloth_free_modifier(pid->ob, pid->data);
@@ -463,11 +862,15 @@ int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
}
if(clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ if(after)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, CFRA);
+ if(current)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, CFRA);
- return (reset || clear);
+ return (reset || clear || current || after);
}
-int BKE_ptcache_object_reset(Object *ob, int mode)
+int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
{
PTCacheID pid;
ParticleSystem *psys;
@@ -479,7 +882,7 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
if(ob->soft) {
BKE_ptcache_id_from_softbody(&pid, ob, ob->soft);
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
@@ -488,23 +891,23 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
if(psys->soft) {
BKE_ptcache_id_from_softbody(&pid, ob, psys->soft);
if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
else
skip = 1;
}
- else if((psys->recalc & PSYS_RECALC_RESET)==0)
+ else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
skip = 1;
if(skip == 0) {
BKE_ptcache_id_from_particles(&pid, ob, psys);
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
for(md=ob->modifiers.first; md; md=md->next) {
if(md->type == eModifierType_Cloth) {
BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md);
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
@@ -564,7 +967,7 @@ void BKE_ptcache_set_continue_physics(Scene *scene, int enable)
if(CONTINUE_PHYSICS == 0) {
for(ob=G.main->object.first; ob; ob=ob->id.next)
- if(BKE_ptcache_object_reset(ob, PTCACHE_RESET_OUTDATED))
+ if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED))
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
@@ -590,6 +993,14 @@ PointCache *BKE_ptcache_add()
void BKE_ptcache_free(PointCache *cache)
{
+ PTCacheMem *pm = cache->mem_cache.first;
+ if(pm) {
+ for(; pm; pm=pm->next)
+ MEM_freeN(pm->data);
+
+ BLI_freelistN(&cache->mem_cache);
+ }
+
MEM_freeN(cache);
}
@@ -605,3 +1016,231 @@ PointCache *BKE_ptcache_copy(PointCache *cache)
return ncache;
}
+
+
+/* Baking */
+void BKE_ptcache_autocache_all(Scene *scene)
+{
+ PTCacheBaker baker;
+
+ baker.bake=0;
+ baker.break_data=NULL;
+ baker.break_test=NULL;
+ baker.pid=NULL;
+ baker.progressbar=NULL;
+ baker.progresscontext=NULL;
+ baker.render=0;
+ baker.scene=scene;
+
+ if(psys_count_autocache(scene, NULL))
+ BKE_ptcache_make_cache(&baker);
+}
+
+/* if bake is not given run simulations to current frame */
+void BKE_ptcache_make_cache(PTCacheBaker* baker)
+{
+ Scene *scene = baker->scene;
+ Base *base;
+ ListBase pidlist;
+ PTCacheID *pid = baker->pid;
+ PointCache *cache;
+ float frameleno = scene->r.framelen;
+ int cfrao = CFRA;
+ int startframe = MAXFRAME;
+ int endframe = CFRA;
+ int bake = baker->bake;
+ int render = baker->render;
+ int end = 0;
+
+ G.afbreek = 0;
+
+ //printf("Caching physics...");
+
+ /* set caches to baking mode and figure out start frame */
+ if(pid) {
+ /* cache/bake a single object */
+ cache = pid->cache;
+ if((cache->flag & PTCACHE_BAKED)==0) {
+ if(pid->type==PTCACHE_TYPE_PARTICLES)
+ psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe);
+
+ if(bake || cache->flag & PTCACHE_OUTDATED)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ startframe = MAX2(cache->last_exact, cache->startframe);
+
+ if(bake) {
+ endframe = cache->endframe;
+ cache->flag |= PTCACHE_BAKING;
+ }
+ else
+ endframe = MIN2(endframe, cache->endframe);
+
+ cache->flag &= ~PTCACHE_BAKED;
+ }
+ }
+ else for(base=scene->base.first; base; base= base->next) {
+ /* cache/bake everything in the scene */
+ BKE_ptcache_ids_from_object(&pidlist, base->object);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ cache = pid->cache;
+ if((cache->flag & PTCACHE_BAKED)==0) {
+ if(pid->type==PTCACHE_TYPE_PARTICLES)
+ psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe);
+
+ if(cache->flag & PTCACHE_OUTDATED)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ startframe = MIN2(startframe, cache->startframe);
+
+ if(bake) {
+ endframe = MAX2(endframe, cache->endframe);
+ cache->flag |= PTCACHE_BAKING;
+ }
+ else if(render)
+ cache->flag |= PTCACHE_BAKING;
+
+ cache->flag &= ~PTCACHE_BAKED;
+
+ }
+ }
+
+ BLI_freelistN(&pidlist);
+ }
+
+ CFRA= startframe;
+ scene->r.framelen = 1.0;
+ scene_update_for_newframe(scene, scene->lay);
+
+ for(; CFRA <= endframe; CFRA++) {
+ float prog;
+
+ if(bake)
+ prog = (int)(100.0 * (float)(CFRA - startframe)/(float)(endframe-startframe));
+ else
+ prog = CFRA;
+
+ /* NOTE: baking should not redraw whole ui as this slows things down */
+ if(baker->progressbar)
+ baker->progressbar(baker->progresscontext, prog);
+
+ scene_update_for_newframe(scene, scene->lay);
+
+ /* NOTE: breaking baking should leave calculated frames in cache, not clear it */
+ if(baker->break_test && baker->break_test(baker->break_data))
+ break;
+ }
+
+ /* clear baking flag */
+ if(pid) {
+ cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
+ if(bake)
+ cache->flag |= PTCACHE_BAKED;
+ }
+ else for(base=scene->base.first; base; base= base->next) {
+ BKE_ptcache_ids_from_object(&pidlist, base->object);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
+ if(bake)
+ cache->flag |= PTCACHE_BAKED;
+ }
+ }
+
+ //printf("done!\n");
+
+ scene->r.framelen = frameleno;
+ CFRA = cfrao;
+ scene_update_for_newframe(scene, scene->lay);
+}
+
+void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) {
+ PointCache *cache = pid->cache;
+ PTCacheFile *pf;
+ PTCacheMem *pm;
+ int totelem=0;
+ int float_count=0;
+ int tot;
+ int write_error=0;
+
+ if (!G.relbase_valid){
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+ return;
+ }
+
+ totelem = ptcache_pid_totelem(pid);
+ float_count = ptcache_pid_elemsize(pid) / sizeof(float);
+
+ if(totelem==0 || float_count==0)
+ return;
+
+ tot = totelem*float_count;
+
+ /* MEM -> DISK */
+ if(cache->flag & PTCACHE_DISK_CACHE) {
+ pm = cache->mem_cache.first;
+
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ for(; pm; pm=pm->next) {
+ pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
+
+ if(pf) {
+ if(fwrite(pm->data, sizeof(float), tot, pf->fp) != tot) {
+ printf("Error writing to disk cache\n");
+
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+
+ BKE_ptcache_file_close(pf);
+ return;
+ }
+ BKE_ptcache_file_close(pf);
+ }
+ else
+ printf("Error creating disk cache file\n");
+ }
+
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ cache->flag |= PTCACHE_DISK_CACHE;
+ }
+ /* DISK -> MEM */
+ else {
+ int cfra;
+ int sfra = cache->startframe;
+ int efra = cache->endframe;
+
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ for(cfra=sfra; cfra <= efra; cfra++) {
+ pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
+
+ if(pf) {
+ pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
+ pm->data = MEM_callocN(sizeof(float)*tot, "Pointcache mem data");
+
+ if(fread(pm->data, sizeof(float), tot, pf->fp)!= tot) {
+ printf("Error reading from disk cache\n");
+
+ cache->flag |= PTCACHE_DISK_CACHE;
+
+ MEM_freeN(pm->data);
+ MEM_freeN(pm);
+ BKE_ptcache_file_close(pf);
+ return;
+ }
+
+ pm->frame = cfra;
+
+ BLI_addtail(&pid->cache->mem_cache, pm);
+
+ BKE_ptcache_file_close(pf);
+ }
+ }
+
+ cache->flag |= PTCACHE_DISK_CACHE;
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+ }
+} \ No newline at end of file
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 156bdae9b00..3b51af57e0b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -142,8 +142,6 @@ void free_scene(Scene *sce)
BLI_freelistN(&sce->base);
seq_free_editing(sce->ed);
- if(sce->radio) MEM_freeN(sce->radio);
- sce->radio= 0;
#ifndef DISABLE_PYTHON
BPY_free_scriptlink(&sce->scriptlink);
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 688a4ab901b..0ae17a13e43 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -62,13 +62,6 @@
#include <sys/vfs.h>
#endif
-#ifdef __BeOS
-struct statfs {
- int f_bsize;
- int f_bfree;
-};
-#endif
-
#ifdef __APPLE__
/* For statfs */
#include <sys/param.h>
@@ -77,7 +70,7 @@ struct statfs {
#include <fcntl.h>
-#if !defined(__BeOS) && !defined(WIN32)
+#if !defined(WIN32)
#include <sys/mtio.h> /* tape comando's */
#endif
#include <string.h> /* strcpy etc.. */
@@ -201,9 +194,6 @@ double BLI_diskfree(char *dir)
#if defined (__FreeBSD__) || defined (linux) || defined (__OpenBSD__) || defined (__APPLE__)
if (statfs(name, &disk)) return(-1);
#endif
-#ifdef __BeOS
- return -1;
-#endif
#if defined (__sun__) || defined (__sun) || defined (__sgi)
if (statvfs(name, &disk)) return(-1);
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index df4ad4e7c75..26f4c2dd415 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -737,10 +737,7 @@ void BLI_splitdirstring(char *di, char *fi)
}
char *BLI_gethome(void) {
- #ifdef __BeOS
- return "/boot/home/"; /* BeOS 4.5: doubleclick at icon doesnt give home env */
-
- #elif !defined(WIN32)
+ #if !defined(WIN32)
return getenv("HOME");
#else /* Windows */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 74226cabba6..af4f61fccc4 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2932,6 +2932,16 @@ static void direct_link_material(FileData *fd, Material *ma)
static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
+ if((cache->flag & PTCACHE_DISK_CACHE)==0) {
+ PTCacheMem *pm;
+
+ link_list(fd, &cache->mem_cache);
+
+ pm = cache->mem_cache.first;
+
+ for(; pm; pm=pm->next)
+ pm->data = newdataadr(fd, pm->data);
+ }
cache->flag &= ~(PTCACHE_SIMULATION_VALID|PTCACHE_BAKE_EDIT_ACTIVE);
cache->simframe= 0;
}
@@ -3196,10 +3206,8 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface);
- if(!mesh->mr->edge_flags)
- mesh->mr->edge_flags= MEM_callocN(sizeof(short)*lvl->totedge, "Multires Edge Flags");
- if(!mesh->mr->edge_creases)
- mesh->mr->edge_creases= MEM_callocN(sizeof(char)*lvl->totedge, "Multires Edge Creases");
+ mesh->mr->edge_flags= newdataadr(fd, mesh->mr->edge_flags);
+ mesh->mr->edge_creases= newdataadr(fd, mesh->mr->edge_creases);
mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
@@ -3987,8 +3995,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
direct_link_keyingsets(fd, &sce->keyingsets);
sce->basact= newdataadr(fd, sce->basact);
-
- sce->radio= newdataadr(fd, sce->radio);
sce->toolsettings= newdataadr(fd, sce->toolsettings);
if(sce->toolsettings) {
@@ -9057,6 +9063,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
Scene *sce;
Tex *tx;
ParticleSettings *part;
+ Object *ob;
for(screen= main->screen.first; screen; screen= screen->id.next) {
do_versions_windowmanager_2_50(screen);
@@ -9099,7 +9106,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
}
- /* particle settings conversion */
+ /* particle draw and render types */
for(part= main->particle.first; part; part= part->id.next) {
if(part->draw_as) {
if(part->draw_as == PART_DRAW_DOT) {
@@ -9115,6 +9122,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+ /* set old pointcaches to have disk cache flag */
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ ParticleSystem *psys = ob->particlesystem.first;
+
+ for(; psys; psys=psys->next) {
+ if(psys->pointcache)
+ psys->pointcache->flag |= PTCACHE_DISK_CACHE;
+ }
+
+ /* TODO: softbody & cloth caches */
+ }
}
/* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 0c385911721..3f591c62dee 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -549,6 +549,22 @@ static void write_userdef(WriteData *wd)
}
}
+/* TODO: replace *cache with *cachelist once it's coded */
+#define PTCACHE_WRITE_PSYS 0
+static void write_pointcaches(WriteData *wd, PointCache *cache, int type)
+{
+ writestruct(wd, DATA, "PointCache", 1, cache);
+
+ if((cache->flag & PTCACHE_DISK_CACHE)==0) {
+ PTCacheMem *pm = cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ writestruct(wd, DATA, "PTCacheMem", 1, pm);
+ if(type==PTCACHE_WRITE_PSYS)
+ writestruct(wd, DATA, "ParticleKey", pm->totpoint, pm->data);
+ }
+ }
+}
static void write_particlesettings(WriteData *wd, ListBase *idbase)
{
ParticleSettings *part;
@@ -585,8 +601,8 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
}
if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child);
writestruct(wd, DATA, "SoftBody", 1, psys->soft);
- if(psys->soft) writestruct(wd, DATA, "PointCache", 1, psys->soft->pointcache);
- writestruct(wd, DATA, "PointCache", 1, psys->pointcache);
+ if(psys->soft) write_pointcaches(wd, psys->soft->pointcache, PTCACHE_WRITE_PSYS);
+ write_pointcaches(wd, psys->pointcache, PTCACHE_WRITE_PSYS);
}
}
@@ -1617,7 +1633,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
base= base->next;
}
- writestruct(wd, DATA, "Radio", 1, sce->radio);
writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings);
if(sce->toolsettings->vpaint)
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint);
diff --git a/source/blender/blenpluginapi/intern/Makefile b/source/blender/blenpluginapi/intern/Makefile
index 51905cad8ec..20a61e9a25c 100644
--- a/source/blender/blenpluginapi/intern/Makefile
+++ b/source/blender/blenpluginapi/intern/Makefile
@@ -33,10 +33,6 @@ DIR = $(OCGDIR)/blender/$(LIBNAME)
include nan_compile.mk
-ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris"))
- CFLAGS += -shared
-endif
-
CFLAGS += $(LEVEL_1_C_WARNINGS)
# path to our own external headerfiles. On win2k this needs to be
diff --git a/source/blender/makesdna/DNA_radio_types.h b/source/blender/editors/include/ED_pointcache.h
index 4219bf59b93..7bf51d9d53d 100644
--- a/source/blender/makesdna/DNA_radio_types.h
+++ b/source/blender/editors/include/ED_pointcache.h
@@ -1,9 +1,5 @@
-/**
- * radio_types.h dec 2000 Nzc
- *
- * All type defs for the Blender core.
- *
- * $Id$
+/*
+ * $Id: ED_editparticle.h $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -21,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * The Original Code is Copyright (C) 2007 by Janne Karhu.
* All rights reserved.
*
* The Original Code is: all of this file.
@@ -29,34 +25,14 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
*/
-#ifndef DNA_RADIO_TYPES_H
-#define DNA_RADIO_TYPES_H
-
-typedef struct Radio {
- short hemires, maxiter;
- short drawtype, flag; /* bit 0 and 1: show limits */
- short subshootp, subshoote, nodelim, maxsublamp;
- short pama, pami, elma, elmi; /* patch and elem limits */
- int maxnode;
- float convergence;
- float radfac, gamma; /* for display */
-
-} Radio;
-
-
-/* **************** RADIOSITY ********************* */
-
-/* draw type */
-#define RAD_WIREFRAME 0
-#define RAD_SOLID 1
-#define RAD_GOURAUD 2
+#ifndef ED_PHYSICS_H
+#define ED_PHYSICS_H
-/* flag */
-#define RAD_SHOWLIMITS 1
-#define RAD_SHOWZ 2
+/* operators */
+void ED_operatortypes_pointcache(void);
+//void ED_keymap_pointcache(struct wmWindowManager *wm);
-#endif
+#endif /* ED_PHYSICS_H */
diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c
new file mode 100644
index 00000000000..e47f44c5c1a
--- /dev/null
+++ b/source/blender/editors/physics/ed_pointcache.c
@@ -0,0 +1,270 @@
+/*
+ * $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) 2007 by Janne Karhu.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_object_force.h"
+
+#include "BKE_context.h"
+#include "BKE_particle.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+#include "BKE_utildefines.h"
+#include "BKE_pointcache.h"
+#include "BKE_global.h"
+#include "BKE_multires.h"
+
+#include "BLI_blenlib.h"
+
+#include "ED_screen.h"
+#include "ED_pointcache.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "physics_intern.h"
+
+static int cache_break_test(void *cbd) {
+ return G.afbreek==1;
+}
+/**************************** general **********************************/
+static int ptcache_bake_all_poll(bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+
+ if(!scene)
+ return 0;
+
+ return 1;
+}
+
+static int ptcache_bake_all_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PTCacheBaker baker;
+
+
+ baker.scene = scene;
+ baker.pid = NULL;
+ baker.bake = RNA_boolean_get(op->ptr, "bake");
+ baker.render = 0;
+ baker.break_test = cache_break_test;
+ baker.break_data = NULL;
+ baker.progressbar = WM_timecursor;
+ baker.progresscontext = CTX_wm_window(C);
+
+ BKE_ptcache_make_cache(&baker);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+static int ptcache_free_bake_all_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Base *base;
+ PTCacheID *pid;
+ ListBase pidlist;
+
+ for(base=scene->base.first; base; base= base->next) {
+ BKE_ptcache_ids_from_object(&pidlist, base->object);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ pid->cache->flag &= ~PTCACHE_BAKED;
+ BKE_ptcache_id_reset(scene, pid, PTCACHE_RESET_OUTDATED);
+ }
+ }
+
+ BLI_freelistN(&pidlist);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void PTCACHE_OT_bake_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake All Physics";
+ ot->idname= "PTCACHE_OT_bake_all";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_all_exec;
+ ot->poll= ptcache_bake_all_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Free All Physics Bakes";
+ ot->idname= "PTCACHE_OT_free_bake_all";
+
+ /* api callbacks */
+ ot->exec= ptcache_free_bake_all_exec;
+ ot->poll= ptcache_bake_all_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/**************************** particles **********************************/
+static int ptcache_bake_particle_system_poll(bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+
+ if(!scene || !ob || ob->id.lib)
+ return 0;
+
+ return (ob->particlesystem.first != NULL);
+}
+
+static int ptcache_bake_particle_system_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ParticleSystem *psys =psys_get_current(ob);
+ PTCacheID pid;
+ PTCacheBaker baker;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+
+ baker.scene = scene;
+ baker.pid = &pid;
+ baker.bake = RNA_boolean_get(op->ptr, "bake");
+ baker.render = 0;
+ baker.break_test = cache_break_test;
+ baker.break_data = NULL;
+ baker.progressbar = WM_timecursor;
+ baker.progresscontext = CTX_wm_window(C);
+
+ BKE_ptcache_make_cache(&baker);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+static int ptcache_free_bake_particle_system_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ParticleSystem *psys= psys_get_current(ob);
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+ psys->pointcache->flag &= ~PTCACHE_BAKED;
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+void PTCACHE_OT_cache_particle_system(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake Particles";
+ ot->idname= "PTCACHE_OT_cache_particle_system";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_particle_system_exec;
+ ot->poll= ptcache_bake_particle_system_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "bake", 0, "Bake", "");
+}
+void PTCACHE_OT_free_bake_particle_system(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Free Particles Bake";
+ ot->idname= "PTCACHE_OT_free_bake_particle_system";
+
+ /* api callbacks */
+ ot->exec= ptcache_free_bake_particle_system_exec;
+ ot->poll= ptcache_bake_particle_system_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+static int ptcache_bake_from_particles_cache_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ ParticleSystem *psys= psys_get_current(ob);
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+ psys->pointcache->flag |= PTCACHE_BAKED;
+
+ return OPERATOR_FINISHED;
+}
+void PTCACHE_OT_bake_from_particles_cache(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake From Cache";
+ ot->idname= "PTCACHE_OT_bake_from_particles_cache";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_from_particles_cache_exec;
+ ot->poll= ptcache_bake_particle_system_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/**************************** registration **********************************/
+
+void ED_operatortypes_pointcache(void)
+{
+ WM_operatortype_append(PTCACHE_OT_bake_all);
+ WM_operatortype_append(PTCACHE_OT_free_bake_all);
+ WM_operatortype_append(PTCACHE_OT_cache_particle_system);
+ WM_operatortype_append(PTCACHE_OT_free_bake_particle_system);
+ WM_operatortype_append(PTCACHE_OT_bake_from_particles_cache);
+}
+
+//void ED_keymap_pointcache(wmWindowManager *wm)
+//{
+// ListBase *keymap= WM_keymap_listbase(wm, "Pointcache", 0, 0);
+//
+// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
+// WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
+// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
+// WM_keymap_add_item(keymap, "PHYSICS_OT_free_particle_system", LKEY, KM_PRESS, 0, 0);
+//}
+
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index fa33e214737..ac86e2ed962 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -148,6 +148,7 @@ typedef struct StrokeCache {
float *layer_disps; /* Displacements for each vertex */
float (*mesh_store)[3]; /* Copy of the mesh vertices' locations */
short (*orig_norms)[3]; /* Copy of the mesh vertices' normals */
+ float (*face_norms)[3]; /* Copy of the mesh faces' normals */
float rotation; /* Texture rotation (radians) for anchored and rake modes */
int pixel_radius, previous_pixel_radius;
ListBase grab_active_verts[8]; /* The same list of verts is used throught grab stroke */
@@ -240,7 +241,6 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1;
float pressure= 1;
float flip= cache->flip ? -1:1;
- float anchored = sd->brush->flag & BRUSH_ANCHORED ? 25 : 1;
if(sd->brush->flag & BRUSH_ALPHA_PRESSURE)
pressure *= cache->pressure;
@@ -250,6 +250,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
case SCULPT_TOOL_INFLATE:
case SCULPT_TOOL_CLAY:
case SCULPT_TOOL_FLATTEN:
+ case SCULPT_TOOL_LAYER:
return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */;
case SCULPT_TOOL_SMOOTH:
return alpha * 4 * pressure;
@@ -257,46 +258,27 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
return alpha / 2 * dir * pressure * flip;
case SCULPT_TOOL_GRAB:
return 1;
- case SCULPT_TOOL_LAYER:
- return sd->brush->alpha / 50.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */;
default:
return 0;
}
}
-/* For clipping against a mirror modifier */
-static void sculpt_clip(StrokeCache *cache, float *co, const float val[3])
+/* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */
+static void sculpt_clip(Sculpt *sd, float *co, const float val[3])
{
int i;
+
for(i=0; i<3; ++i) {
- if((cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= cache->clip_tolerance[i]))
+ if(sd->flags & (SCULPT_LOCK_X << i))
+ continue;
+
+ if((sd->session->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= sd->session->cache->clip_tolerance[i]))
co[i]= 0.0f;
else
co[i]= val[i];
}
}
-static void sculpt_axislock(Sculpt *sd, float *co)
-{
- if(sd->flags == (SCULPT_LOCK_X|SCULPT_LOCK_Y|SCULPT_LOCK_Z))
- return;
-
- if(sd->session->cache->vc.v3d->twmode == V3D_MANIP_LOCAL) {
- float mat[3][3], imat[3][3];
- Mat3CpyMat4(mat, sd->session->cache->vc.obact->obmat);
- Mat3Inv(imat, mat);
- Mat3MulVecfl(mat, co);
- if (sd->flags & SCULPT_LOCK_X) co[0] = 0.0;
- if (sd->flags & SCULPT_LOCK_Y) co[1] = 0.0;
- if (sd->flags & SCULPT_LOCK_Z) co[2] = 0.0;
- Mat3MulVecfl(imat, co);
- } else {
- if (sd->flags & SCULPT_LOCK_X) co[0] = 0.0;
- if (sd->flags & SCULPT_LOCK_Y) co[1] = 0.0;
- if (sd->flags & SCULPT_LOCK_Z) co[2] = 0.0;
- }
-}
-
static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], const short no[3])
{
float fno[3] = {no[0], no[1], no[2]};
@@ -353,8 +335,6 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_
calc_area_normal(sd, area_normal, active_verts);
- sculpt_axislock(sd, area_normal);
-
while(node){
float *co= ss->mvert[node->Index].co;
@@ -362,7 +342,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_
co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1],
co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]};
- sculpt_clip(ss->cache, co, val);
+ sculpt_clip(sd, co, val);
node= node->next;
}
@@ -412,37 +392,37 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert)
VecCopyf(avg, ss->mvert[vert].co);
}
-static void do_smooth_brush(SculptSession *ss, const ListBase* active_verts)
+static void do_smooth_brush(Sculpt *s, const ListBase* active_verts)
{
ActiveData *node= active_verts->first;
int i;
for(i = 0; i < 2; ++i) {
while(node){
- float *co= ss->mvert[node->Index].co;
+ float *co= s->session->mvert[node->Index].co;
float avg[3], val[3];
- neighbor_average(ss, avg, node->Index);
+ neighbor_average(s->session, avg, node->Index);
val[0] = co[0]+(avg[0]-co[0])*node->Fade;
val[1] = co[1]+(avg[1]-co[1])*node->Fade;
val[2] = co[2]+(avg[2]-co[2])*node->Fade;
- sculpt_clip(ss->cache, co, val);
+ sculpt_clip(s, co, val);
node= node->next;
}
}
}
-static void do_pinch_brush(SculptSession *ss, const ListBase* active_verts)
+static void do_pinch_brush(Sculpt *s, const ListBase* active_verts)
{
ActiveData *node= active_verts->first;
while(node) {
- float *co= ss->mvert[node->Index].co;
- const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade,
- co[1]+(ss->cache->location[1]-co[1])*node->Fade,
- co[2]+(ss->cache->location[2]-co[2])*node->Fade};
- sculpt_clip(ss->cache, co, val);
+ float *co= s->session->mvert[node->Index].co;
+ const float val[3]= {co[0]+(s->session->cache->location[0]-co[0])*node->Fade,
+ co[1]+(s->session->cache->location[1]-co[1])*node->Fade,
+ co[2]+(s->session->cache->location[2]-co[2])*node->Fade};
+ sculpt_clip(s, co, val);
node= node->next;
}
}
@@ -454,7 +434,6 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
float grab_delta[3];
VecCopyf(grab_delta, ss->cache->grab_delta_symmetry);
- sculpt_axislock(sd, grab_delta);
while(node) {
float *co= ss->mvert[node->Index].co;
@@ -462,7 +441,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
VecCopyf(add, grab_delta);
VecMulf(add, node->Fade);
VecAddf(add, add, co);
- sculpt_clip(ss->cache, co, add);
+ sculpt_clip(sd, co, add);
node= node->next;
}
@@ -473,42 +452,38 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active
{
float area_normal[3];
ActiveData *node= active_verts->first;
- float lim= brush_strength(sd, ss->cache);
+ float lim= ss->cache->radius / 4;
- if(sd->brush->flag & BRUSH_DIR_IN)
+ if(ss->cache->flip)
lim = -lim;
calc_area_normal(sd, area_normal, active_verts);
while(node){
float *disp= &ss->cache->layer_disps[node->Index];
+ float *co= ss->mvert[node->Index].co;
+ float val[3];
- if((lim > 0 && *disp < lim) ||
- (lim < 0 && *disp > lim)) {
- float *co= ss->mvert[node->Index].co;
- float val[3];
-
- *disp+= node->Fade;
-
- if(lim < 0 && *disp < lim)
- *disp = lim;
- else if(lim > 0 && *disp > lim)
- *disp = lim;
-
- val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0];
- val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1];
- val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2];
- //VecMulf(val, ss->cache->radius);
- sculpt_clip(ss->cache, co, val);
- }
+ *disp+= node->Fade;
+
+ /* Don't let the displacement go past the limit */
+ if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim))
+ *disp = lim;
+
+ val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0];
+ val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1];
+ val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2];
+
+ sculpt_clip(sd, co, val);
node= node->next;
}
}
-static void do_inflate_brush(SculptSession *ss, const ListBase *active_verts)
+static void do_inflate_brush(Sculpt *s, const ListBase *active_verts)
{
ActiveData *node= active_verts->first;
+ SculptSession *ss = s->session;
float add[3];
while(node) {
@@ -524,7 +499,7 @@ static void do_inflate_brush(SculptSession *ss, const ListBase *active_verts)
add[2]*= ss->cache->scale[2];
VecAddf(add, add, co);
- sculpt_clip(ss->cache, co, add);
+ sculpt_clip(s, co, add);
node= node->next;
}
@@ -587,7 +562,7 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase
VecAddf(val, val, tmp);
}
- sculpt_clip(ss->cache, co, val);
+ sculpt_clip(sd, co, val);
node= node->next;
}
@@ -845,13 +820,13 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache)
do_draw_brush(sd, ss, &active_verts);
break;
case SCULPT_TOOL_SMOOTH:
- do_smooth_brush(ss, &active_verts);
+ do_smooth_brush(sd, &active_verts);
break;
case SCULPT_TOOL_PINCH:
- do_pinch_brush(ss, &active_verts);
+ do_pinch_brush(sd, &active_verts);
break;
case SCULPT_TOOL_INFLATE:
- do_inflate_brush(ss, &active_verts);
+ do_inflate_brush(sd, &active_verts);
break;
case SCULPT_TOOL_GRAB:
do_grab_brush(sd, ss);
@@ -1192,6 +1167,11 @@ void sculptmode_draw_mesh(int only_damaged)
}
#endif
+static int sculpt_mode_poll(bContext *C)
+{
+ return G.f & G_SCULPTMODE;
+}
+
static int sculpt_poll(bContext *C)
{
return G.f & G_SCULPTMODE && CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
@@ -1269,7 +1249,7 @@ static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot)
ot->idname= "SCULPT_OT_brush_curve_preset";
ot->exec= sculpt_brush_curve_preset_exec;
- ot->poll= sculpt_poll;
+ ot->poll= sculpt_mode_poll;
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1334,6 +1314,8 @@ static void sculpt_cache_free(StrokeCache *cache)
MEM_freeN(cache->mesh_store);
if(cache->orig_norms)
MEM_freeN(cache->orig_norms);
+ if(cache->face_norms)
+ MEM_freeN(cache->face_norms);
if(cache->mats)
MEM_freeN(cache->mats);
MEM_freeN(cache);
@@ -1362,9 +1344,11 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *
sculpt_update_mesh_elements(C);
+ if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER)
+ cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements");
+
/* Make copies of the mesh vertex locations and normals for some tools */
if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) {
- cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements");
cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * sd->session->totvert, "sculpt mesh vertices copy");
for(i = 0; i < sd->session->totvert; ++i)
VecCopyf(cache->mesh_store[i], sd->session->mvert[i].co);
@@ -1376,6 +1360,13 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *
cache->orig_norms[i][1] = sd->session->mvert[i].no[1];
cache->orig_norms[i][2] = sd->session->mvert[i].no[2];
}
+
+ if(sd->session->face_normals) {
+ float *fn = sd->session->face_normals;
+ cache->face_norms= MEM_mallocN(sizeof(float) * 3 * sd->session->totface, "Sculpt face norms");
+ for(i = 0; i < sd->session->totface; ++i, fn += 3)
+ VecCopyf(cache->face_norms[i], fn);
+ }
}
}
@@ -1502,17 +1493,27 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
static void sculpt_restore_mesh(Sculpt *sd)
{
- StrokeCache *cache = sd->session->cache;
+ SculptSession *ss = sd->session;
+ StrokeCache *cache = ss->cache;
int i;
/* Restore the mesh before continuing with anchored stroke */
if((sd->brush->flag & BRUSH_ANCHORED) && cache->mesh_store) {
- for(i = 0; i < sd->session->totvert; ++i) {
- VecCopyf(sd->session->mvert[i].co, cache->mesh_store[i]);
- sd->session->mvert[i].no[0] = cache->orig_norms[i][0];
- sd->session->mvert[i].no[1] = cache->orig_norms[i][1];
- sd->session->mvert[i].no[2] = cache->orig_norms[i][2];
+ for(i = 0; i < ss->totvert; ++i) {
+ VecCopyf(ss->mvert[i].co, cache->mesh_store[i]);
+ ss->mvert[i].no[0] = cache->orig_norms[i][0];
+ ss->mvert[i].no[1] = cache->orig_norms[i][1];
+ ss->mvert[i].no[2] = cache->orig_norms[i][2];
+ }
+
+ if(ss->face_normals) {
+ float *fn = ss->face_normals;
+ for(i = 0; i < ss->totface; ++i, fn += 3)
+ VecCopyf(fn, cache->face_norms[i]);
}
+
+ if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER)
+ memset(cache->layer_disps, 0, sizeof(float) * ss->totvert);
}
}
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 4f9c1f4b7a7..510103895f4 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -50,6 +50,7 @@
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_uvedit.h"
+#include "ED_pointcache.h"
/* only call once on startup, storage is global in BKE kernel listbase */
void ED_spacetypes_init(void)
@@ -89,6 +90,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_curve();
ED_operatortypes_armature();
ED_marker_operatortypes();
+ ED_operatortypes_pointcache();
ui_view2d_operatortypes();
diff --git a/source/blender/editors/space_buttons/SConscript b/source/blender/editors/space_buttons/SConscript
index 541da52f7f9..a0a7dad4077 100644
--- a/source/blender/editors/space_buttons/SConscript
+++ b/source/blender/editors/space_buttons/SConscript
@@ -12,7 +12,4 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('GAMEBLENDER=1')
- if env['WITH_BF_SOLID']:
- defs.append('USE_SUMO_SOLID')
-
env.BlenderLib ( 'bf_editors_space_buttons', sources, Split(incs), defs, libtype=['core'], priority=[120] )
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 38ce88019ed..e5d2215be29 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -220,14 +220,23 @@ void buttons_keymap(struct wmWindowManager *wm)
}
+//#define PY_HEADER
/* add handlers, stuff you only do once or on area/region changes */
static void buttons_header_area_init(wmWindowManager *wm, ARegion *ar)
{
+#ifdef PY_HEADER
+ ED_region_header_init(ar);
+#else
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+#endif
}
static void buttons_header_area_draw(const bContext *C, ARegion *ar)
{
+#ifdef PY_HEADER
+ ED_region_header(C, ar);
+#else
+
float col[3];
/* clear */
@@ -243,7 +252,8 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(C, &ar->v2d);
buttons_header_buttons(C, ar);
-
+#endif
+
/* restore view matrix? */
UI_view2d_view_restore(C);
}
diff --git a/source/blender/editors/space_info/SConscript b/source/blender/editors/space_info/SConscript
index 05afcae162e..01268115687 100644
--- a/source/blender/editors/space_info/SConscript
+++ b/source/blender/editors/space_info/SConscript
@@ -11,7 +11,4 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('GAMEBLENDER=1')
- if env['WITH_BF_SOLID']:
- defs.append('USE_SUMO_SOLID')
-
env.BlenderLib ( 'bf_editors_space_info', sources, Split(incs), defs, libtype=['core'], priority=[70] )
diff --git a/source/blender/editors/space_logic/SConscript b/source/blender/editors/space_logic/SConscript
index 46a9858a836..e32fcc1b535 100644
--- a/source/blender/editors/space_logic/SConscript
+++ b/source/blender/editors/space_logic/SConscript
@@ -12,7 +12,4 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('GAMEBLENDER=1')
- if env['WITH_BF_SOLID']:
- defs.append('USE_SUMO_SOLID')
-
env.BlenderLib ( 'bf_editors_space_game', sources, Split(incs), defs, libtype=['core'], priority=[120] )
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index a67e8c8a1c3..42da6775d5f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3239,6 +3239,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(draw_as!=PART_DRAW_PATH){
state.time=cfra;
if(psys_get_particle_state(scene,ob,psys,a,&state,0)){
+ if(psys->parent)
+ Mat4MulVecfl(psys->parent->obmat, state.co);
+
/* create actiual particle data */
switch(draw_as){
case PART_DRAW_DOT:
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index fb7d9c57eaf..cb210a37bf4 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4809,7 +4809,7 @@ void special_aftertrans_update(TransInfo *t)
if (base->flag & SELECT && (t->mode != TFM_DUMMY)) {
/* pointcache refresh */
- if (BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH))
+ if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
/* Set autokey if necessary */
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 4d721a83c78..76b3f58f75c 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -26,6 +26,7 @@
#include <math.h>
#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
#include "BLI_arithb.h"
diff --git a/source/blender/editors/transform/transform_ndofinput.c b/source/blender/editors/transform/transform_ndofinput.c
index c52492ebd6b..9c2a1a7db6d 100644
--- a/source/blender/editors/transform/transform_ndofinput.c
+++ b/source/blender/editors/transform/transform_ndofinput.c
@@ -31,6 +31,7 @@
#include "BKE_utildefines.h" /* ABS */
#include "DNA_view3d_types.h" /* for G.vd (view3d) */
+#include "DNA_windowmanager_types.h" /* for G.vd (view3d) */
#include "WM_types.h"
diff --git a/source/blender/editors/transform/transform_numinput.c b/source/blender/editors/transform/transform_numinput.c
index 34976105db3..f5f1d5fac9e 100644
--- a/source/blender/editors/transform/transform_numinput.c
+++ b/source/blender/editors/transform/transform_numinput.c
@@ -34,6 +34,7 @@
#include "BKE_utildefines.h" /* ABS */
#include "WM_types.h"
+#include "DNA_windowmanager_types.h"
#include "transform.h"
diff --git a/source/blender/gpu/intern/Makefile b/source/blender/gpu/intern/Makefile
index 733ee3f764c..3a3ac20ff6c 100644
--- a/source/blender/gpu/intern/Makefile
+++ b/source/blender/gpu/intern/Makefile
@@ -35,7 +35,7 @@ DIR = $(OCGDIR)/blender/$(LIBNAME)
include nan_compile.mk
-ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows"))
+ifeq ($(OS),$(findstring $(OS), "darwin freebsd linux openbsd solaris windows"))
CFLAGS += -funsigned-char
endif
diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h
index bd2a0d3082f..7b5d668ce2b 100644
--- a/source/blender/imbuf/intern/imbuf.h
+++ b/source/blender/imbuf/intern/imbuf.h
@@ -51,7 +51,7 @@
#include <sys/mman.h>
#endif
-#if !defined(WIN32) && !defined(__BeOS)
+#if !defined(WIN32)
#define O_BINARY 0
#endif
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 6df92f69fff..1a6ab104bcf 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -244,26 +244,6 @@ struct ImBuf *IMB_loadifffile(int file, int flags) {
size = BLI_filesize(file);
-#if defined(AMIGA) || defined(__BeOS)
- mem= (int *)malloc(size);
- if (mem==0) {
- printf("Out of mem\n");
- return (0);
- }
-
- if (read(file, mem, size)!=size){
- printf("Read Error\n");
- free(mem);
- return (0);
- }
-
- ibuf = IMB_ibImageFromMemory(mem, size, flags);
- free(mem);
-
- /* for jpeg read */
- lseek(file, 0L, SEEK_SET);
-
-#else
mem= (int *)mmap(0,size,PROT_READ,MAP_SHARED,file,0);
if (mem==(int *)-1){
printf("Couldn't get mapping\n");
@@ -275,7 +255,6 @@ struct ImBuf *IMB_loadifffile(int file, int flags) {
if (munmap( (void *) mem, size)){
printf("Couldn't unmap file.\n");
}
-#endif
return(ibuf);
}
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 718d1a17834..a8d402fc503 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -33,6 +33,8 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+#include "DNA_listBase.h"
typedef struct PartDeflect {
short deflect; /* Deflection flag - does mesh deflect particles*/
@@ -72,12 +74,25 @@ typedef struct PartDeflect {
int seed; /* wind noise random seed */
} PartDeflect;
+typedef struct PTCacheMem {
+ struct PTCacheMem *next, *prev;
+ int frame, totpoint;
+ float *data; /* data points */
+ void *xdata; /* extra data */
+} PTCacheMem;
+
typedef struct PointCache {
- int flag; /* generic flag */
+ int flag, rt; /* generic flag */
int simframe; /* current frame of simulation (only if SIMULATION_VALID) */
int startframe; /* simulation start frame */
int endframe; /* simulation end frame */
int editframe; /* frame being edited (runtime only) */
+ int last_exact; /* last exact frame that's cached */
+ int xdata_type; /* type of extra data */
+ char name[64];
+ char prev_name[64];
+ char info[64];
+ struct ListBase mem_cache;
} PointCache;
typedef struct SBVertex {
@@ -247,6 +262,8 @@ typedef struct SoftBody {
#define PTCACHE_BAKING 8
#define PTCACHE_BAKE_EDIT 16
#define PTCACHE_BAKE_EDIT_ACTIVE 32
+#define PTCACHE_DISK_CACHE 64
+#define PTCACHE_AUTOCACHE 128
/* ob->softflag */
#define OB_SB_ENABLE 1
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 6805082d094..b10f35b9091 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -192,6 +192,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in
struct Object *target_ob;
struct Object *keyed_ob;
struct Object *lattice;
+ struct Object *parent; /* particles from global space -> parent space */
struct ListBase effectors, reactevents; /* runtime */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 2219535bfd3..89db9ae3ee8 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -39,7 +39,6 @@ extern "C" {
#include "DNA_scriptlink_types.h"
#include "DNA_ID.h"
-struct Radio;
struct Object;
struct World;
struct Scene;
@@ -158,7 +157,7 @@ typedef struct SceneRenderLayer {
#define SCE_PASS_REFRACT 1024
#define SCE_PASS_INDEXOB 2048
#define SCE_PASS_UV 4096
-#define SCE_PASS_RADIO 8192
+#define SCE_PASS_RADIO 8192 /* Radio removed, can use for new GI? */
#define SCE_PASS_MIST 16384
/* note, srl->passflag is treestore element 'nr' in outliner, short still... */
@@ -570,7 +569,6 @@ typedef struct Scene {
struct bNodeTree *nodetree;
void *ed; /* sequence editor data is allocated here */
- struct Radio *radio;
struct GameFraming framing;
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 7d6b5ec8764..e02d2984771 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -222,5 +222,36 @@ typedef enum wmRadialControlMode {
WM_RADIALCONTROL_ANGLE
} wmRadialControlMode;
+/* ************** wmEvent ************************ */
+/* for read-only rna access, dont save this */
+
+/* each event should have full modifier state */
+/* event comes from eventmanager and from keymap */
+typedef struct wmEvent {
+ struct wmEvent *next, *prev;
+
+ short type; /* event code itself (short, is also in keymap) */
+ short val; /* press, release, scrollvalue */
+ short x, y; /* mouse pointer position, screen coord */
+ short mval[2]; /* region mouse position, name convention pre 2.5 :) */
+ short prevx, prevy; /* previous mouse pointer position */
+ short unicode; /* future, ghost? */
+ char ascii; /* from ghost */
+ char pad;
+
+ /* modifier states */
+ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
+ short keymodifier; /* rawkey modifier */
+
+ /* keymap item, set by handler (weak?) */
+ const char *keymap_idname;
+
+ /* custom data */
+ short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
+ void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
+ short customdatafree;
+
+} wmEvent;
+
#endif /* DNA_WINDOWMANAGER_TYPES_H */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index bf2f0f3900e..91e9e617ea9 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -98,7 +98,6 @@ char *includefiles[] = {
"DNA_object_force.h",
"DNA_object_fluidsim.h",
"DNA_world_types.h",
- "DNA_radio_types.h",
"DNA_scene_types.h",
"DNA_view3d_types.h",
"DNA_view2d_types.h",
@@ -1124,7 +1123,6 @@ int main(int argc, char ** argv)
#include "DNA_object_force.h"
#include "DNA_object_fluidsim.h"
#include "DNA_world_types.h"
-#include "DNA_radio_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "DNA_view2d_types.h"
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 01abc5450aa..af64daa3293 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -172,6 +172,7 @@ extern StructRNA RNA_EnvironmentMap;
extern StructRNA RNA_EnvironmentMapTexture;
extern StructRNA RNA_ExplodeModifier;
extern StructRNA RNA_ExpressionController;
+extern StructRNA RNA_Event;
extern StructRNA RNA_FCurve;
extern StructRNA RNA_FModifier;
extern StructRNA RNA_FModifierCycles;
@@ -546,6 +547,9 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax);
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision);
+int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier);
+int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name);
+
void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem);
int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index c679d9fc544..276f421c586 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -40,6 +40,9 @@ extern EnumPropertyItem beztriple_interpolation_mode_items[];
extern EnumPropertyItem fmodifier_type_items[];
+extern EnumPropertyItem event_value_items[];
+extern EnumPropertyItem event_type_items[];
+
#endif /* RNA_ENUM_TYPES */
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 18734fbcb18..9ece6684cd8 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1854,7 +1854,6 @@ RNAProcessItem PROCESS_ITEMS[]= {
{"rna_particle.c", NULL, RNA_def_particle},
{"rna_pose.c", NULL, RNA_def_pose},
{"rna_property.c", NULL, RNA_def_gameproperty},
- {"rna_radio.c", NULL, RNA_def_radio},
{"rna_scene.c", NULL, RNA_def_scene},
{"rna_screen.c", NULL, RNA_def_screen},
{"rna_scriptlink.c", NULL, RNA_def_scriptlink},
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index ba893319ce9..13686809cd2 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -669,6 +669,28 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden
return 0;
}
+int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier)
+{
+ for (; item->identifier; item++) {
+ if(item->value==value) {
+ *identifier = item->identifier;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name)
+{
+ for (; item->identifier; item++) {
+ if(item->value==value) {
+ *name = item->name;
+ return 1;
+ }
+ }
+ return 0;
+}
+
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
{
const EnumPropertyItem *item;
@@ -676,14 +698,7 @@ int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int v
RNA_property_enum_items(ptr, prop, &item, &totitem);
- for(i=0; i<totitem; i++) {
- if(item[i].value==value) {
- *identifier = item[i].identifier;
- return 1;
- }
- }
-
- return 0;
+ return RNA_enum_identifier(item, value, identifier);
}
const char *RNA_property_ui_name(PropertyRNA *prop)
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index a3d5c4fe388..c2f2e1d519f 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -146,7 +146,6 @@ void RNA_def_object_force(struct BlenderRNA *brna);
void RNA_def_packedfile(struct BlenderRNA *brna);
void RNA_def_particle(struct BlenderRNA *brna);
void RNA_def_pose(struct BlenderRNA *brna);
-void RNA_def_radio(struct BlenderRNA *brna);
void RNA_def_rna(struct BlenderRNA *brna);
void RNA_def_scene(struct BlenderRNA *brna);
void RNA_def_screen(struct BlenderRNA *brna);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index d144ed5f28b..bc3f0733a0d 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -32,8 +32,87 @@
#include "DNA_object_types.h"
#include "DNA_object_force.h"
+#include "WM_types.h"
+
#ifdef RNA_RUNTIME
+#include "MEM_guardedalloc.h"
+
+#include "BKE_context.h"
+#include "BKE_pointcache.h"
+
+#include "BLI_blenlib.h"
+
+static void rna_Cache_toggle_disk_cache(bContext *C, PointerRNA *ptr)
+{
+ Object *ob = CTX_data_active_object(C);
+ PointCache *cache = (PointCache*)ptr->data;
+ PTCacheID *pid = NULL;
+ ListBase pidlist;
+
+ if(!ob)
+ return;
+
+ BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ if(pid->cache==cache)
+ break;
+ }
+
+ if(pid)
+ BKE_ptcache_toggle_disk_cache(pid);
+
+ BLI_freelistN(&pidlist);
+}
+
+static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr)
+{
+ Object *ob = CTX_data_active_object(C);
+ PointCache *cache = (PointCache*)ptr->data;
+ PTCacheID *pid = NULL, *pid2;
+ ListBase pidlist;
+ int new_name = 1;
+ char name[80];
+
+ if(!ob)
+ return;
+
+ /* TODO: check for proper characters */
+
+ BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ if(pid->cache==cache)
+ pid2 = pid;
+ else if(strcmp(cache->name, "") && strcmp(cache->name,pid->cache->name)==0) {
+ /*TODO: report "name exists" to user */
+ strcpy(cache->name, cache->prev_name);
+ new_name = 0;
+ }
+ }
+
+ if(new_name) {
+ if(pid2 && cache->flag & PTCACHE_DISK_CACHE) {
+ strcpy(name, cache->name);
+ strcpy(cache->name, cache->prev_name);
+
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+
+ BKE_ptcache_toggle_disk_cache(pid2);
+
+ strcpy(cache->name, name);
+
+ cache->flag |= PTCACHE_DISK_CACHE;
+
+ BKE_ptcache_toggle_disk_cache(pid2);
+ }
+
+ strcpy(cache->prev_name, cache->name);
+ }
+
+ BLI_freelistN(&pidlist);
+}
#else
static void rna_def_pointcache(BlenderRNA *brna)
@@ -60,6 +139,32 @@ static void rna_def_pointcache(BlenderRNA *brna)
prop= RNA_def_property(srna, "baking", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING);
+
+ prop= RNA_def_property(srna, "disk_cache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_DISK_CACHE);
+ RNA_def_property_ui_text(prop, "Disk Cache", "Save cache files to disk");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
+
+ prop= RNA_def_property(srna, "outdated", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_OUTDATED);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Cache is outdated", "");
+
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Name", "Cache name");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
+
+ prop= RNA_def_property(srna, "autocache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_AUTOCACHE);
+ RNA_def_property_ui_text(prop, "Auto Cache", "Cache changes automatically");
+ //RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_autocache");
+
+ prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "info");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status.");
+
}
static void rna_def_collision(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 8ee71b6fd9e..c48c1006588 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -38,6 +38,7 @@
#include "DNA_scene_types.h"
#include "WM_types.h"
+#include "WM_api.h"
#ifdef RNA_RUNTIME
@@ -45,48 +46,93 @@
#include "BKE_depsgraph.h"
#include "BKE_particle.h"
+#include "BLI_arithb.h"
+
+/* property update functions */
static void rna_Particle_redo(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_REDO;
+
+ if(ob)
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ }
+ else {
part = ptr->id.data;
-
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_REDO);
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_REDO);
+ }
}
static void rna_Particle_reset(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
- part = ptr->id.data;
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_REDO);
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_RESET;
+
+ if(ob) {
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
+ }
+ else {
+ part = ptr->id.data;
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_RESET);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
}
static void rna_Particle_change_type(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
- part = ptr->id.data;
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE|PSYS_RECALC_REDO);
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_RESET|PSYS_RECALC_TYPE;
+
+ if(ob) {
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
+ }
+ else {
+ part = ptr->id.data;
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
}
static void rna_Particle_redo_child(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
+
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_CHILD;
+
+ if(ob)
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ }
+ else {
part = ptr->id.data;
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_CHILD);
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_CHILD);
+ }
}
static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value)
{
@@ -887,7 +933,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "disp");
RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3d view");
- RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
+ RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset");
prop= RNA_def_property(srna, "material", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "omat");
@@ -1669,6 +1715,14 @@ static void rna_def_particle_system(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
RNA_def_property_struct_type(prop, "PointCache");
RNA_def_property_ui_text(prop, "Point Cache", "");
+
+ /* offset ob */
+ prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "parent");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Parent", "Use this object's coordinate system instead of global coordinate system.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
+
}
void RNA_def_particle(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_radio.c b/source/blender/makesrna/intern/rna_radio.c
deleted file mode 100644
index 8b862b4c535..00000000000
--- a/source/blender/makesrna/intern/rna_radio.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * $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.
- *
- * Contributor(s): Blender Foundation (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-
-#include "RNA_define.h"
-#include "RNA_types.h"
-
-#include "rna_internal.h"
-
-#include "DNA_radio_types.h"
-
-#ifdef RNA_RUNTIME
-
-#else
-
-void RNA_def_radio(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static EnumPropertyItem prop_drawtype_items[] = {
- {RAD_WIREFRAME, "WIREFRAME", 0, "Wireframe", "Enables Wireframe draw mode"},
- {RAD_SOLID, "SOLID", 0, "Solid", "Enables Solid draw mode"},
- {RAD_GOURAUD, "GOURAUD", 0, "Gouraud", "Enables Gouraud draw mode"},
- {0, NULL, 0, NULL, NULL}};
-
- srna= RNA_def_struct(brna, "Radiosity", NULL);
- RNA_def_struct_ui_text(srna, "Radiosity", "Settings for radiosity simulation of indirect diffuse lighting.");
- RNA_def_struct_sdna(srna, "Radio");
-
- /* Enums */
- prop= RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "drawtype");
- RNA_def_property_enum_items(prop, prop_drawtype_items);
- RNA_def_property_ui_text(prop, "Draw Mode", "Radiosity draw modes.");
-
- /* Number values */
- prop= RNA_def_property(srna, "hemi_resolution", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "hemires");
- RNA_def_property_range(prop, 100, 1000);
- RNA_def_property_ui_text(prop, "Hemi Resolution", "Sets the size of a hemicube.");
-
- prop= RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxiter");
- RNA_def_property_range(prop, 0, 10000);
- RNA_def_property_ui_text(prop, "Max Iterations", "Limits the maximum number of radiosity rounds.");
-
- prop= RNA_def_property(srna, "multiplier", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "radfac");
- RNA_def_property_range(prop, 0.001f, 250.0f);
- RNA_def_property_ui_text(prop, "Multiplier", "Multiplies the energy values.");
-
- prop= RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "gamma");
- RNA_def_property_range(prop, 0.2f, 10.0f);
- RNA_def_property_ui_text(prop, "Gamma", "Changes the contrast of the energy values.");
-
- prop= RNA_def_property(srna, "convergence", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "convergence");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Convergence", "Sets the lower threshold of unshot energy.");
-
- prop= RNA_def_property(srna, "element_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "elma");
- RNA_def_property_range(prop, 1, 500);
- RNA_def_property_ui_text(prop, "Element Max", "Sets maximum size of an element");
-
- prop= RNA_def_property(srna, "element_min", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "elmi");
- RNA_def_property_range(prop, 1, 100);
- RNA_def_property_ui_text(prop, "Element Min", "Sets minimum size of an element");
-
- prop= RNA_def_property(srna, "patch_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "pama");
- RNA_def_property_range(prop, 10, 1000);
- RNA_def_property_ui_text(prop, "Patch Max", "Sets maximum size of a patch.");
-
- prop= RNA_def_property(srna, "patch_min", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "pami");
- RNA_def_property_range(prop, 10, 1000);
- RNA_def_property_ui_text(prop, "Patch Min", "Sets minimum size of a patch.");
-
- prop= RNA_def_property(srna, "subshoot_patch", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "subshootp");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "SubShoot Patch", "Sets the number of times the environment is tested to detect paths.");
-
- prop= RNA_def_property(srna, "subshoot_element", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "subshoote");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "SubShoot Element", "Sets the number of times the environment is tested to detect elements.");
-
- prop= RNA_def_property(srna, "max_elements", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxnode");
- RNA_def_property_range(prop, 1, 250000);
- RNA_def_property_ui_text(prop, "Max Elements", "Sets the maximum allowed number of elements.");
-
- prop= RNA_def_property(srna, "max_subdiv_shoot", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxsublamp");
- RNA_def_property_range(prop, 1, 250);
- RNA_def_property_ui_text(prop, "Max Subdiv Shoot", "Sets the maximum number of initial shoot patches that are evaluated");
-
- prop= RNA_def_property(srna, "remove_doubles_limit", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "nodelim");
- RNA_def_property_range(prop, 0, 50);
- RNA_def_property_ui_text(prop, "Remove Doubles Limit", "Sets the range for removing doubles");
-
- /* flag */
- prop= RNA_def_property(srna, "show_limits", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", RAD_SHOWLIMITS);
- RNA_def_property_ui_text(prop, "Show Limits", "Draws patch and element limits");
-
- prop= RNA_def_property(srna, "show_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", RAD_SHOWZ);
- RNA_def_property_ui_text(prop, "Show Z", "Draws limits differently");
-}
-
-#endif
-
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 1365ab75fc7..5d4916bb3c6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -923,10 +923,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "ed");
RNA_def_property_struct_type(prop, "SequenceEditor");
RNA_def_property_ui_text(prop, "Sequence Editor", "");
-
- prop= RNA_def_property(srna, "radiosity", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "radio");
- RNA_def_property_ui_text(prop, "Radiosity", "");
prop= RNA_def_property(srna, "keyingsets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index d4f7c5b0bd1..ce31cb27c9a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -575,18 +575,17 @@ static void rna_def_space_buttons(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem buttons_context_items[] = {
- {BCONTEXT_SCENE, "SCENE", 0, "Scene", ""},
- {BCONTEXT_WORLD, "WORLD", 0, "World", ""},
- {BCONTEXT_OBJECT, "OBJECT", 0, "Object", ""},
- {BCONTEXT_DATA, "DATA", 0, "Data", ""},
- {BCONTEXT_MATERIAL, "MATERIAL", 0, "Material", ""},
- {BCONTEXT_TEXTURE, "TEXTURE", 0, "Texture", ""},
- {BCONTEXT_PARTICLE, "PARTICLE", 0, "Particle", ""},
- {BCONTEXT_PHYSICS, "PHYSICS", 0, "Physics", ""},
- {BCONTEXT_GAME, "GAME", 0, "Game", ""},
- {BCONTEXT_BONE, "BONE", 0, "Bone", ""},
- {BCONTEXT_MODIFIER, "MODIFIER", 0, "Modifier", ""},
- {BCONTEXT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""},
+ {BCONTEXT_SCENE, "SCENE", ICON_SCENE, "Scene", "Scene"},
+ {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
+ {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
+ {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraint", "Constraint"},
+ {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifier", "Modifier"},
+ {BCONTEXT_DATA, "DATA", 0, "Data", "Data"},
+ {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone"},
+ {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
+ {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"},
+ {BCONTEXT_PARTICLE, "PARTICLE", ICON_PARTICLES, "Particle", "Particle"},
+ {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem panel_alignment_items[] = {
@@ -602,11 +601,13 @@ static void rna_def_space_buttons(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "mainb");
RNA_def_property_enum_items(prop, buttons_context_items);
RNA_def_property_ui_text(prop, "Buttons Context", "The type of active data to display and edit in the buttons window");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
prop= RNA_def_property(srna, "panel_alignment", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "align");
RNA_def_property_enum_items(prop, panel_alignment_items);
RNA_def_property_ui_text(prop, "Panel Alignment", "Arrangement of the panels within the buttons window");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
/* pinned data */
prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index df07e03850a..a1b51084fca 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -30,6 +30,120 @@
#include "rna_internal.h"
#include "DNA_windowmanager_types.h"
+#include "WM_types.h" /* wmEvent */
+
+
+EnumPropertyItem event_value_items[] = {
+ {KM_ANY, "ANY", 0, "Any", ""},
+ {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
+ {KM_PRESS, "PRESS", 0, "Press", ""},
+ {KM_RELEASE, "RELEASE", 0, "Release", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+/* not returned: CAPSLOCKKEY, UNKNOWNKEY, COMMANDKEY, GRLESSKEY */
+EnumPropertyItem event_type_items[] = {
+ {AKEY, "A", 0, "A", ""},
+ {BKEY, "B", 0, "B", ""},
+ {CKEY, "C", 0, "C", ""},
+ {DKEY, "D", 0, "D", ""},
+ {EKEY, "E", 0, "E", ""},
+ {FKEY, "F", 0, "F", ""},
+ {GKEY, "G", 0, "G", ""},
+ {HKEY, "H", 0, "H", ""},
+ {IKEY, "I", 0, "I", ""},
+ {JKEY, "J", 0, "J", ""},
+ {KKEY, "K", 0, "K", ""},
+ {LKEY, "L", 0, "L", ""},
+ {MKEY, "M", 0, "M", ""},
+ {NKEY, "N", 0, "N", ""},
+ {OKEY, "O", 0, "O", ""},
+ {PKEY, "P", 0, "P", ""},
+ {QKEY, "Q", 0, "Q", ""},
+ {RKEY, "R", 0, "R", ""},
+ {SKEY, "S", 0, "S", ""},
+ {TKEY, "T", 0, "T", ""},
+ {UKEY, "U", 0, "U", ""},
+ {VKEY, "V", 0, "V", ""},
+ {WKEY, "W", 0, "W", ""},
+ {XKEY, "X", 0, "X", ""},
+ {YKEY, "Y", 0, "Y", ""},
+ {ZKEY, "Z", 0, "Z", ""},
+
+ {ZEROKEY, "ZERO", 0, "Zero Key", ""},
+ {ONEKEY, "ONE", 0, "One Key", ""},
+ {TWOKEY, "TWO", 0, "Two Key", ""},
+ {THREEKEY, "THREE", 0, "Three Key", ""},
+ {FOURKEY, "FOUR", 0, "Four Key", ""},
+ {FIVEKEY, "FIVE", 0, "Five Key", ""},
+ {SIXKEY, "SIX", 0, "Six Key", ""},
+ {SEVENKEY, "SEVEN", 0, "Seven Key", ""},
+ {EIGHTKEY, "EIGHT", 0, "Eight Key", ""},
+ {NINEKEY, "NINE", 0, "Nine Key", ""},
+
+ {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""},
+ {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""},
+ {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""},
+ {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Rightctrl", ""},
+ {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Rightshift", ""},
+ {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Leftshift", ""},
+
+ {ESCKEY, "ESC", 0, "Esc", ""},
+ {TABKEY, "TAB", 0, "Tab", ""},
+ {RETKEY, "RET", 0, "Return", ""},
+ {SPACEKEY, "SPACE", 0, "Spacebar", ""},
+ {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
+ {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""},
+ {DELKEY, "DEL", 0, "Delete", ""},
+ {SEMICOLONKEY, "SEMI_COLON", 0, "Semicolon", ""},
+ {PERIODKEY, "PERIOD", 0, "Period", ""},
+ {COMMAKEY, "COMMA", 0, "Comma", ""},
+ {QUOTEKEY, "QUOTE", 0, "Quote", ""},
+ {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "Accentgrave", ""},
+ {MINUSKEY, "MINUS", 0, "Minus", ""},
+ {SLASHKEY, "SLASH", 0, "Slash", ""},
+ {BACKSLASHKEY, "BACK_SLASH", 0, "Backslash", ""},
+ {EQUALKEY, "EQUAL", 0, "Equal", ""},
+ {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "Leftbracket", ""},
+ {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "Rightbracket", ""},
+ {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""},
+ {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""},
+ {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""},
+ {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", ""},
+ {PAD2, "NUMPAD_2", 0, "Numpad 2", ""},
+ {PAD4, "NUMPAD_4", 0, "Numpad 4", ""},
+ {PAD6, "NUMPAD_6", 0, "Numpad 6", ""},
+ {PAD8, "NUMPAD_8", 0, "Numpad 8", ""},
+ {PAD1, "NUMPAD_1", 0, "Numpad 1", ""},
+ {PAD3, "NUMPAD_3", 0, "Numpad 3", ""},
+ {PAD5, "NUMPAD_5", 0, "Numpad 5", ""},
+ {PAD7, "NUMPAD_7", 0, "Numpad 7", ""},
+ {PAD9, "NUMPAD_9", 0, "Numpad 9", ""},
+ {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", ""},
+ {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", ""},
+ {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", ""},
+ {PAD0, "NUMPAD_0", 0, "Numpad 0", ""},
+ {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", ""},
+ {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", ""},
+ {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", ""},
+ {F1KEY, "F1", 0, "F1", ""},
+ {F2KEY, "F2", 0, "F2", ""},
+ {F3KEY, "F3", 0, "F3", ""},
+ {F4KEY, "F4", 0, "F4", ""},
+ {F5KEY, "F5", 0, "F5", ""},
+ {F6KEY, "F6", 0, "F6", ""},
+ {F7KEY, "F7", 0, "F7", ""},
+ {F8KEY, "F8", 0, "F8", ""},
+ {F9KEY, "F9", 0, "F9", ""},
+ {F10KEY, "F10", 0, "F10", ""},
+ {F11KEY, "F11", 0, "F11", ""},
+ {F12KEY, "F12", 0, "F12", ""},
+ {PAUSEKEY, "PAUSE", 0, "Pause", ""},
+ {INSERTKEY, "INSERT", 0, "Insert", ""},
+ {HOMEKEY, "HOME", 0, "Home", ""},
+ {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""},
+ {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
+ {ENDKEY, "END", 0, "End", ""},
+ {0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
@@ -87,6 +201,20 @@ static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties);
}
+
+static int rna_Event_ascii_get(PointerRNA *ptr, char *value)
+{
+ wmEvent *event= (wmEvent*)ptr->id.data;
+ value[0]= event->ascii;
+ value[1]= '\0';
+}
+
+static int rna_Event_ascii_length(PointerRNA *ptr)
+{
+ wmEvent *event= (wmEvent*)ptr->id.data;
+ return (event->ascii)? 1 : 0;
+}
+
#else
static void rna_def_operator(BlenderRNA *brna)
@@ -146,7 +274,80 @@ static void rna_def_operator_filelist_element(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Name", "the name of a file or directory within a file list");
}
+
+static void rna_def_event(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "Event", NULL);
+ RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
+ RNA_def_struct_sdna(srna, "wmEvent");
+
+ /* strings */
+ prop= RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
+ RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event.");
+
+
+ /* enums */
+ prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "val");
+ RNA_def_property_enum_items(prop, event_value_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some.");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, event_type_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Type", "");
+
+
+ /* mouse */
+ prop= RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "x");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse.");
+
+ prop= RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "y");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse.");
+
+ prop= RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "prevx");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse.");
+
+ prop= RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "prevy");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse.");
+
+ /* modifiers */
+ prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Shift", "True when the shift key is held.");
+
+ prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Ctrl", "True when the shift key is held.");
+
+ prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Alt", "True when the shift key is held.");
+
+ prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "OS Key", "True when the shift key is held.");
+}
static void rna_def_windowmanager(BlenderRNA *brna)
{
@@ -169,6 +370,7 @@ void RNA_def_wm(BlenderRNA *brna)
rna_def_operator(brna);
rna_def_operator_utils(brna);
rna_def_operator_filelist_element(brna);
+ rna_def_event(brna);
rna_def_windowmanager(brna);
}
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index 4dba61411f0..f5eb81e3cea 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -337,7 +337,7 @@ void RNA_def_world(BlenderRNA *brna)
static EnumPropertyItem physics_engine_items[] = {
{WOPHY_NONE, "NONE", 0, "None", ""},
//{WOPHY_ENJI, "ENJI", 0, "Enji", ""},
- {WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""},
+ //{WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""},
//{WOPHY_DYNAMO, "DYNAMO", 0, "Dynamo", ""},
//{WOPHY_ODE, "ODE", 0, "ODE", ""},
{WOPHY_BULLET, "BULLET", 0, "Bullet", ""},
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index f4fdd0c6194..542de6bd9b8 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -47,98 +47,6 @@
#define PYOP_ATTR_IDNAME "__name__" /* use pythons class name */
#define PYOP_ATTR_DESCRIPTION "__doc__" /* use pythons docstring */
-static PyObject *pyop_dict_from_event(wmEvent *event)
-{
- PyObject *dict= PyDict_New();
- PyObject *item;
- char *cstring, ascii[2];
-
- /* type */
- item= PyUnicode_FromString(WM_key_event_string(event->type));
- PyDict_SetItemString(dict, "type", item); Py_DECREF(item);
-
- /* val */
- switch(event->val) {
- case KM_ANY:
- cstring = "ANY";
- break;
- case KM_RELEASE:
- cstring = "RELEASE";
- break;
- case KM_PRESS:
- cstring = "PRESS";
- break;
- default:
- cstring = "UNKNOWN";
- break;
- }
-
- item= PyUnicode_FromString(cstring);
- PyDict_SetItemString(dict, "val", item); Py_DECREF(item);
-
- /* x, y (mouse) */
- item= PyLong_FromLong(event->x);
- PyDict_SetItemString(dict, "x", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->y);
- PyDict_SetItemString(dict, "y", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->prevx);
- PyDict_SetItemString(dict, "prevx", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->prevy);
- PyDict_SetItemString(dict, "prevy", item); Py_DECREF(item);
-
- /* ascii */
- ascii[0]= event->ascii;
- ascii[1]= '\0';
- item= PyUnicode_FromString(ascii);
- PyDict_SetItemString(dict, "ascii", item); Py_DECREF(item);
-
- /* modifier keys */
- item= PyLong_FromLong(event->shift);
- PyDict_SetItemString(dict, "shift", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->ctrl);
- PyDict_SetItemString(dict, "ctrl", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->alt);
- PyDict_SetItemString(dict, "alt", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->oskey);
- PyDict_SetItemString(dict, "oskey", item); Py_DECREF(item);
-
-
-
- /* modifier */
-#if 0
- item= PyTuple_New(0);
- if(event->keymodifier & KM_SHIFT) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("SHIFT"));
- size++;
- }
- if(event->keymodifier & KM_CTRL) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("CTRL"));
- size++;
- }
- if(event->keymodifier & KM_ALT) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("ALT"));
- size++;
- }
- if(event->keymodifier & KM_OSKEY) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("OSKEY"));
- size++;
- }
- PyDict_SetItemString(dict, "keymodifier", item); Py_DECREF(item);
-#endif
-
- return dict;
-}
-
static struct BPY_flag_def pyop_ret_flags[] = {
{"RUNNING_MODAL", OPERATOR_RUNNING_MODAL},
{"CANCELLED", OPERATOR_CANCELLED},
@@ -180,6 +88,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
int ret_flag= (mode==PYOP_POLL ? 0:OPERATOR_CANCELLED);
PointerRNA ptr_context;
PointerRNA ptr_operator;
+ PointerRNA ptr_event;
PyObject *py_operator;
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -230,11 +139,13 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
if (mode==PYOP_INVOKE) {
item= PyObject_GetAttrString(py_class, "invoke");
args = PyTuple_New(3);
+
+ RNA_pointer_create(NULL, &RNA_Event, event, &ptr_event);
// PyTuple_SET_ITEM "steals" object reference, it is
// an object passed shouldn't be DECREF'ed
PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context));
- PyTuple_SET_ITEM(args, 2, pyop_dict_from_event(event));
+ PyTuple_SET_ITEM(args, 2, pyrna_struct_CreatePyObject(&ptr_event));
}
else if (mode==PYOP_EXEC) {
item= PyObject_GetAttrString(py_class, "execute");
diff --git a/source/blender/radiosity/CMakeLists.txt b/source/blender/radiosity/CMakeLists.txt
deleted file mode 100644
index e76f7409f99..00000000000
--- a/source/blender/radiosity/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# $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): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-FILE(GLOB SRC intern/source/*.c)
-
-SET(INC
- extern/include ../blenlib ../blenkernel ../makesdna ../editors/include
- ../../../intern/guardedalloc ../render/extern/include
- ../render/intern/include ../blenloader ../../../extern/glew/include
-)
-
-BLENDERLIB_NOLIST(blender_radiosity "${SRC}" "${INC}")
-#env.BlenderLib ( 'blender_radiosity', sources, Split(incs), [], libtype='core', priority=50 )
diff --git a/source/blender/radiosity/Makefile b/source/blender/radiosity/Makefile
deleted file mode 100644
index 91a13e2fd57..00000000000
--- a/source/blender/radiosity/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $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) 2001-2002 by NaN Holding BV.
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): none yet.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# Makes module object directory and bounces make to subdirectories.
-
-SOURCEDIR = source/blender/radiosity
-DIRS = intern
-
-include nan_subdirs.mk
diff --git a/source/blender/radiosity/SConscript b/source/blender/radiosity/SConscript
deleted file mode 100644
index 29854d2ee83..00000000000
--- a/source/blender/radiosity/SConscript
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-Import ('env')
-
-sources = env.Glob('intern/source/*.c')
-
-incs = 'extern/include ../blenlib ../blenkernel ../makesdna ../editors/include'
-incs += ' #/intern/guardedalloc ../render/extern/include'
-incs += ' ../render/intern/include ../blenloader #/extern/glew/include'
-
-incs += ' ' + env['BF_OPENGL_INC']
-
-env.BlenderLib ( 'bf_radiosity', sources, Split(incs), [], libtype='core', priority=150 )
diff --git a/source/blender/radiosity/extern/include/radio.h b/source/blender/radiosity/extern/include/radio.h
deleted file mode 100644
index e7f23302880..00000000000
--- a/source/blender/radiosity/extern/include/radio.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/* ***************************************
-
-
-
- radio.h nov/dec 1992
- revised for Blender may 1999
-
- $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) 2001-2002 by NaN Holding BV.
- All rights reserved.
-
- The Original Code is: all of this file.
-
- Contributor(s): none yet.
-
- ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef RADIO_H
-#define RADIO_H
-#define RADIO_H
-
-/* type include */
-#include "radio_types.h"
-
-extern RadGlobal RG;
-struct View3D;
-struct Scene;
-
-/* radfactors.c */
-extern float calcStokefactor(RPatch *shoot, RPatch *rp, RNode *rn, float *area);
-extern void calcTopfactors(void);
-void calcSidefactors(void);
-extern void initradiosity(void);
-extern void rad_make_hocos(RadView *vw);
-extern void hemizbuf(RadView *vw);
-extern int makeformfactors(RPatch *shoot);
-extern void applyformfactors(RPatch *shoot);
-extern RPatch *findshootpatch(void);
-extern void setnodeflags(RNode *rn, int flag, int set);
-extern void backface_test(RPatch *shoot);
-extern void clear_backface_test(void);
-extern void progressiverad(void);
-extern void minmaxradelem(RNode *rn, float *min, float *max);
-extern void minmaxradelemfilt(RNode *rn, float *min, float *max, float *errmin, float *errmax);
-extern void subdivideshootElements(int it);
-extern void subdivideshootPatches(int it);
-extern void inithemiwindows(void);
-extern void closehemiwindows(void);
-void rad_init_energy(void);
-
-/* radio.c */
-void freeAllRad(struct Scene *scene);
-int rad_phase(void);
-void rad_status_str(char *str);
-void rad_printstatus(void);
-void rad_setlimits(struct Scene *scene);
-void set_radglobal(struct Scene *scene);
-void add_radio(struct Scene *scene);
-void delete_radio(struct Scene *scene);
-int rad_go(struct Scene *scene);
-void rad_subdivshootpatch(struct Scene *scene);
-void rad_subdivshootelem(struct Scene *scene);
-void rad_limit_subdivide(struct Scene *scene);
-
-/* radnode.c */
-extern void setnodelimit(float limit);
-extern float *mallocVert(void);
-extern float *callocVert(void);
-extern void freeVert(float *vert);
-extern int totalRadVert(void);
-extern RNode *mallocNode(void);
-extern RNode *callocNode(void);
-extern void freeNode(RNode *node);
-extern void freeNode_recurs(RNode *node);
-extern RPatch *mallocPatch(void);
-extern RPatch *callocPatch(void);
-extern void freePatch(RPatch *patch);
-extern void replaceAllNode(RNode *, RNode *);
-extern void replaceAllNodeInv(RNode *neighb, RNode *old);
-extern void replaceAllNodeUp(RNode *neighb, RNode *old);
-extern void replaceTestNode(RNode *, RNode **, RNode *, int , float *);
-extern void free_fastAll(void);
-
-/* radnode.c */
-extern void start_fastmalloc(char *str);
-extern int setvertexpointersNode(RNode *neighb, RNode *node, int level, float **v1, float **v2);
-extern float edlen(float *v1, float *v2);
-extern void deleteNodes(RNode *node);
-extern void subdivideTriNode(RNode *node, RNode *edge);
-extern void subdivideNode(RNode *node, RNode *edge);
-extern int comparelevel(RNode *node, RNode *nb, int level);
-
-/* radpreprocess.c */
-extern void splitconnected(void);
-extern int vergedge(const void *v1,const void *v2);
-extern void addedge(float *v1, float *v2, EdSort *es);
-extern void setedgepointers(void);
-extern void rad_collect_meshes(struct Scene *scene, struct View3D *v3d);
-extern void countelem(RNode *rn);
-extern void countglobaldata(void);
-extern void addelem(RNode ***el, RNode *rn, RPatch *rp);
-extern void makeGlobalElemArray(void);
-extern void remakeGlobaldata(void);
-extern void splitpatch(RPatch *old);
-extern void addpatch(RPatch *old, RNode *rn);
-extern void converttopatches(void);
-extern void make_elements(void);
-extern void subdividelamps(void);
-extern void maxsizePatches(void);
-extern void subdiv_elements(void);
-
-/* radpostprocess.c */
-void addaccu(register char *z, register char *t);
-void addaccuweight(register char *z, register char *t, int w);
-void triaweight(Face *face, int *w1, int *w2, int *w3);
-void init_face_tab(void);
-Face *addface(void);
-Face *makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn);
-void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int flag);
-void anchorTriface(RNode *rn, float *v1, float *v2, float *v3, int flag);
-float *findmiddlevertex(RNode *node, RNode *nb, float *v1, float *v2);
-void make_face_tab(void);
-void filterFaces(void);
-void calcfiltrad(RNode *rn, float *cd);
-void filterNodes(void);
-void removeEqualNodes(short limit);
-void rad_addmesh(struct Scene *scene);
-void rad_replacemesh(struct Scene *scene);
-
-/* raddisplay.c */
-extern char calculatecolor(float col);
-extern void make_node_display(void);
-extern void drawnodeWire(RNode *rn);
-extern void drawsingnodeWire(RNode *rn);
-extern void drawnodeSolid(RNode *rn);
-extern void drawnodeGour(RNode *rn);
-extern void drawpatch(RPatch *patch, unsigned int col);
-extern void drawfaceGour(Face *face);
-extern void drawfaceSolid(Face *face);
-extern void drawfaceWire(Face *face);
-extern void drawsquare(float *cent, float size, short cox, short coy);
-extern void drawlimits(void);
-extern void setcolNode(RNode *rn, unsigned int *col);
-extern void pseudoAmb(void);
-extern void rad_forcedraw(void);
-extern void drawpatch_ext(RPatch *patch, unsigned int col);
-extern void RAD_drawall(int depth_is_on);
-
-/* radrender.c */
-struct Render;
-extern void do_radio_render(struct Render *re);
-void end_radio_render(void);
-
-#endif /* RADIO_H */
-
diff --git a/source/blender/radiosity/extern/include/radio_types.h b/source/blender/radiosity/extern/include/radio_types.h
deleted file mode 100644
index 5a218ee71be..00000000000
--- a/source/blender/radiosity/extern/include/radio_types.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * radio_types.h
- *
- * $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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/* #include "misc_util.h" */ /* for listbase...*/
-
-
-#ifndef RADIO_TYPES_H
-#define RADIO_TYPES_H
-
-#include "DNA_listBase.h"
-#include "DNA_material_types.h"
-
-struct Render;
-struct CustomData;
-
-#define PI M_PI
-#define RAD_MAXFACETAB 1024
-#define RAD_NEXTFACE(a) if( ((a) & 1023)==0 ) face= RG.facebase[(a)>>10]; else face++;
-
-/* RG.phase */
-#define RAD_SHOOTE 1
-#define RAD_SHOOTP 2
-#define RAD_SOLVE 3
-
-typedef struct RadView {
- float cam[3], tar[3], up[3];
- float wx1, wx2, wy1, wy2;
- float mynear, myfar;
- float viewmat[4][4], winmat[4][4];
- unsigned int *rect, *rectz;
- short rectx, recty;
- int wid;
-
-} RadView;
-
-/* rn->f */
-#define RAD_PATCH 1
-#define RAD_SHOOT 2
-#define RAD_SUBDIV 4
-#define RAD_BACKFACE 8
-#define RAD_TWOSIDED 16
-
-
-typedef struct RNode { /* length: 104 */
- struct RNode *down1, *down2, *up;
- struct RNode *ed1, *ed2, *ed3, *ed4;
- struct RPatch *par;
-
- char lev1, lev2, lev3, lev4; /* edgelevels */
- short type; /* type: 4==QUAD, 3==TRIA */
- short f;
- float *v1, *v2, *v3, *v4;
- float totrad[3], area;
-
- unsigned int col;
- int orig; /* index in custom face data */
-} RNode;
-
-
-typedef struct Face { /* length: 52 */
- float *v1, *v2, *v3, *v4;
- unsigned int col, matindex;
- int orig; /* index in custom face data */
-} Face;
-
-/* rp->f1 */
-#define RAD_NO_SPLIT 1
-
-typedef struct RPatch {
- struct RPatch *next, *prev;
- RNode *first; /* first node==patch */
-
- struct Object *from;
-
- int type; /* 3: TRIA, 4: QUAD */
- short f, f1; /* flags f: if node, only for subdiv */
-
- float ref[3], emit[3], unshot[3];
- float cent[3], norm[3];
- float area;
- int matindex;
-
-} RPatch;
-
-
-typedef struct VeNoCo { /* needed for splitconnected */
- struct VeNoCo *next;
- float *v;
- float *n;
- float *col;
- int flag;
-} VeNoCo;
-
-
-typedef struct EdSort { /* sort edges */
- float *v1, *v2;
- RNode *node;
- int nr;
-} EdSort;
-
-typedef struct {
- struct Radio *radio;
- unsigned int *hemibuf;
- struct ListBase patchbase;
- int totpatch, totelem, totvert, totlamp;
- RNode **elem; /* global array with all pointers */
- VeNoCo *verts; /* temporal vertices from patches */
- float *formfactors; /* 1 factor per element */
- float *topfactors, *sidefactors; /* LUT for delta's */
- int *index; /* LUT for above LUT */
- Face **facebase;
- int totface;
- float min[3], max[3], size[3], cent[3]; /* world */
- float maxsize, totenergy;
- float patchmin, patchmax;
- 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;
-
- /* for preserving face data */
- int mfdatatot;
- struct CustomData *mfdata;
- struct RNode **mfdatanodes;
-
- /* this part is a copy of struct Radio */
- short hemires, maxiter;
- short drawtype, flag; /* bit 0 en 1: show limits */
- short subshootp, subshoote, nodelim, maxsublamp;
- int maxnode;
- float convergence;
- float radfac, gamma; /* for display */
-
-} RadGlobal;
-
-#endif /* radio_types.h */
-
diff --git a/source/blender/radiosity/intern/Makefile b/source/blender/radiosity/intern/Makefile
deleted file mode 100644
index 456b51cc56e..00000000000
--- a/source/blender/radiosity/intern/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $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) 2001-2002 by NaN Holding BV.
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): none yet.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# Makes module object directory and bounces make to subdirectories.
-
-SOURCEDIR = source/blender/radiosity/intern
-DIRS = source
-
-include nan_subdirs.mk
diff --git a/source/blender/radiosity/intern/source/Makefile b/source/blender/radiosity/intern/source/Makefile
deleted file mode 100644
index 44b38de9bae..00000000000
--- a/source/blender/radiosity/intern/source/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# $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) 2001-2002 by NaN Holding BV.
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): none yet.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# radiosity uses the render lib
-#
-
-LIBNAME = radiosity
-DIR = $(OCGDIR)/blender/$(LIBNAME)
-
-include nan_compile.mk
-
-CFLAGS += $(LEVEL_1_C_WARNINGS)
-
-CPPFLAGS += -I$(NAN_GLEW)/include
-CPPFLAGS += -I$(OPENGL_HEADERS)
-
-# not very neat....
-CPPFLAGS += -I../../../blenkernel
-CPPFLAGS += -I../../../blenlib
-CPPFLAGS += -I../../../makesdna
-CPPFLAGS += -I../../../imbuf
-CPPFLAGS += -I../../../
-CPPFLAGS += -I../../../blenloader
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
-
-# first /include is my own includes, second are the external includes
-# third is the external interface. there should be a nicer way to say this
-CPPFLAGS += -I../include -I../../../editors/include -I../../extern/include
-CPPFLAGS += -I../../../render/extern/include
-CPPFLAGS += -I../../../render/intern/include
diff --git a/source/blender/radiosity/intern/source/raddisplay.c b/source/blender/radiosity/intern/source/raddisplay.c
deleted file mode 100644
index ab9e8eedc28..00000000000
--- a/source/blender/radiosity/intern/source/raddisplay.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- raddisplay.c nov/dec 1992
- may 1999
-
- - drawing
- - color calculation for display during solving
-
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BLI_blenlib.h"
-
-#include "DNA_radio_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "DNA_view3d_types.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "BIF_gl.h"
-
-#include "radio.h"
-
-/* cpack has to be endian-insensitive! (old irisgl function) */
-#define cpack(x) glColor3ub( ((x)&0xFF), (((x)>>8)&0xFF), (((x)>>16)&0xFF) )
-
-char calculatecolor(float col)
-{
- int b;
-
- if(RG.gamma==1.0) {
- b= RG.radfactor*col;
- }
- else if(RG.gamma==2.0) {
- b= RG.radfactor*sqrt(col);
- }
- else {
- b= RG.radfactor*pow(col, RG.igamma);
- }
-
- if(b>255) b=255;
- return b;
-}
-
-void make_node_display()
-{
- RNode *rn, **el;
- int a;
- char *charcol;
-
- RG.igamma= 1.0/RG.gamma;
- RG.radfactor= RG.radfac*pow(64*64, RG.igamma);
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- charcol= (char *)&( rn->col );
-
- charcol[3]= calculatecolor(rn->totrad[0]);
- charcol[2]= calculatecolor(rn->totrad[1]);
- charcol[1]= calculatecolor(rn->totrad[2]);
-
- /* gouraudcolor */
- *(rn->v1+3)= 0;
- *(rn->v2+3)= 0;
- *(rn->v3+3)= 0;
- if(rn->v4) *(rn->v4+3)= 0;
- }
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- addaccuweight( (char *)&(rn->col), (char *)(rn->v1+3), 16 );
- addaccuweight( (char *)&(rn->col), (char *)(rn->v2+3), 16 );
- addaccuweight( (char *)&(rn->col), (char *)(rn->v3+3), 16 );
- if(rn->v4) addaccuweight( (char *)&(rn->col), (char *)(rn->v4+3), 16 );
- }
-}
-
-void drawnodeWire(RNode *rn)
-{
-
- if(rn->down1) {
- drawnodeWire(rn->down1);
- drawnodeWire(rn->down2);
- }
- else {
- glBegin(GL_LINE_LOOP);
- glVertex3fv(rn->v1);
- glVertex3fv(rn->v2);
- glVertex3fv(rn->v3);
- if(rn->type==4) glVertex3fv(rn->v4);
- glEnd();
- }
-}
-
-void drawsingnodeWire(RNode *rn)
-{
-
- glBegin(GL_LINE_LOOP);
- glVertex3fv(rn->v1);
- glVertex3fv(rn->v2);
- glVertex3fv(rn->v3);
- if(rn->type==4) glVertex3fv(rn->v4);
- glEnd();
-}
-
-void drawnodeSolid(RNode *rn)
-{
- char *cp;
-
- if(rn->down1) {
- drawnodeSolid(rn->down1);
- drawnodeSolid(rn->down2);
- }
- else {
- cp= (char *)&rn->col;
- glColor3ub(cp[3], cp[2], cp[1]);
- glBegin(GL_POLYGON);
- glVertex3fv(rn->v1);
- glVertex3fv(rn->v2);
- glVertex3fv(rn->v3);
- if(rn->type==4) glVertex3fv(rn->v4);
- glEnd();
- }
-}
-
-void drawnodeGour(RNode *rn)
-{
- char *cp;
-
- if(rn->down1) {
- drawnodeGour(rn->down1);
- drawnodeGour(rn->down2);
- }
- else {
- glBegin(GL_POLYGON);
- cp= (char *)(rn->v1+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v1);
-
- cp= (char *)(rn->v2+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v2);
-
- cp= (char *)(rn->v3+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v3);
-
- if(rn->type==4) {
- cp= (char *)(rn->v4+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v4);
- }
- glEnd();
- }
-}
-
-void drawpatch_ext(RPatch *patch, unsigned int col)
-{
- ScrArea *sa, *oldsa;
- View3D *v3d;
- glDrawBuffer(GL_FRONT);
-
- return; // XXX
-
- cpack(col);
-
- oldsa= NULL; // XXX curarea;
-
-// sa= G.curscreen->areabase.first;
- while(sa) {
- if (sa->spacetype==SPACE_VIEW3D) {
- v3d= sa->spacedata.first;
-
- /* use mywinget() here: otherwise it draws in header */
-// XXX if(sa->win != mywinget()) areawinset(sa->win);
-// XXX persp(PERSP_VIEW);
- if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
- drawnodeWire(patch->first);
- if(v3d->zbuf) glEnable(GL_DEPTH_TEST); // pretty useless?
- }
- sa= sa->next;
- }
-
-// XXX if(oldsa && oldsa!=curarea) areawinset(oldsa->win);
-
- glFlush();
- glDrawBuffer(GL_BACK);
-}
-
-
-void drawfaceGour(Face *face)
-{
- char *cp;
-
- glBegin(GL_POLYGON);
- cp= (char *)(face->v1+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v1);
-
- cp= (char *)(face->v2+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v2);
-
- cp= (char *)(face->v3+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v3);
-
- if(face->v4) {
- cp= (char *)(face->v4+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v4);
- }
- glEnd();
-
-}
-
-void drawfaceSolid(Face *face)
-{
- char *cp;
-
- cp= (char *)&face->col;
- glColor3ub(cp[3], cp[2], cp[1]);
-
- glBegin(GL_POLYGON);
- glVertex3fv(face->v1);
- glVertex3fv(face->v2);
- glVertex3fv(face->v3);
- if(face->v4) {
- glVertex3fv(face->v4);
- }
- glEnd();
-
-}
-
-void drawfaceWire(Face *face)
-{
- char *cp;
-
- cp= (char *)&face->col;
- glColor3ub(cp[3], cp[2], cp[1]);
-
- glBegin(GL_LINE_LOOP);
- glVertex3fv(face->v1);
- glVertex3fv(face->v2);
- glVertex3fv(face->v3);
- if(face->v4) {
- glVertex3fv(face->v4);
- }
- glEnd();
-
-}
-
-void drawsquare(float *cent, float size, short cox, short coy)
-{
- float vec[3];
-
- vec[0]= cent[0];
- vec[1]= cent[1];
- vec[2]= cent[2];
-
- glBegin(GL_LINE_LOOP);
- vec[cox]+= .5*size;
- vec[coy]+= .5*size;
- glVertex3fv(vec);
- vec[coy]-= size;
- glVertex3fv(vec);
- vec[cox]-= size;
- glVertex3fv(vec);
- vec[coy]+= size;
- glVertex3fv(vec);
- glEnd();
-}
-
-void drawlimits()
-{
- /* center around cent */
- short cox=0, coy=1;
-
- if((RG.flag & (RAD_SHOWLIMITS|RAD_SHOWZ))==RAD_SHOWZ) coy= 2;
- if((RG.flag & (RAD_SHOWLIMITS|RAD_SHOWZ))==(RAD_SHOWLIMITS|RAD_SHOWZ)) {
- cox= 1;
- coy= 2;
- }
-
- cpack(0);
- drawsquare(RG.cent, sqrt(RG.patchmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.patchmin), cox, coy);
-
- drawsquare(RG.cent, sqrt(RG.elemmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.elemmin), cox, coy);
-
- cpack(0xFFFFFF);
- drawsquare(RG.cent, sqrt(RG.patchmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.patchmin), cox, coy);
- cpack(0xFFFF00);
- drawsquare(RG.cent, sqrt(RG.elemmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.elemmin), cox, coy);
-
-}
-
-void setcolNode(RNode *rn, unsigned int *col)
-{
-
- if(rn->down1) {
- setcolNode(rn->down1, col);
- setcolNode(rn->down2, col);
- }
- rn->col= *col;
-
- *((unsigned int *)rn->v1+3)= *col;
- *((unsigned int *)rn->v2+3)= *col;
- *((unsigned int *)rn->v3+3)= *col;
- if(rn->v4) *((unsigned int *)rn->v4+3)= *col;
-}
-
-void pseudoAmb()
-{
- RPatch *rp;
- float fac;
- char col[4];
-
- /* sets pseudo ambient color in the nodes */
-
- rp= RG.patchbase.first;
- while(rp) {
-
- if(rp->emit[0]!=0.0 || rp->emit[1]!=0.0 || rp->emit[2]!=0.0) {
- col[1]= col[2]= col[3]= 255;
- }
- else {
- fac= rp->norm[0]+ rp->norm[1]+ rp->norm[2];
- fac= 225.0*(3+fac)/6.0;
-
- col[3]= fac*rp->ref[0];
- col[2]= fac*rp->ref[1];
- col[1]= fac*rp->ref[2];
- }
-
- setcolNode(rp->first, (unsigned int *)col);
-
- rp= rp->next;
- }
-}
-
-void RAD_drawall(int depth_is_on)
-{
- /* displays elements or faces */
- Face *face = NULL;
- RNode **el;
- RPatch *rp;
- int a;
-
- if(!depth_is_on) {
- glEnable(GL_DEPTH_TEST);
- glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT);
- }
-
- if(RG.totface) {
- if(RG.drawtype==RAD_GOURAUD) {
- glShadeModel(GL_SMOOTH);
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
-
- drawfaceGour(face);
- }
- }
- else if(RG.drawtype==RAD_SOLID) {
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
-
- drawfaceSolid(face);
- }
- }
- else {
- cpack(0);
- rp= RG.patchbase.first;
- while(rp) {
- drawsingnodeWire(rp->first);
- rp= rp->next;
- }
- }
- }
- else {
- el= RG.elem;
- if(RG.drawtype==RAD_GOURAUD) {
- glShadeModel(GL_SMOOTH);
- for(a=RG.totelem; a>0; a--, el++) {
- drawnodeGour(*el);
- }
- }
- else if(RG.drawtype==RAD_SOLID) {
- for(a=RG.totelem; a>0; a--, el++) {
- drawnodeSolid(*el);
- }
- }
- else {
- cpack(0);
- for(a=RG.totelem; a>0; a--, el++) {
- drawnodeWire(*el);
- }
- }
- }
- glShadeModel(GL_FLAT);
-
- if(RG.totpatch) {
- if(RG.flag & (RAD_SHOWLIMITS|RAD_SHOWZ)) {
- if(depth_is_on) glDisable(GL_DEPTH_TEST);
- drawlimits();
- if(depth_is_on) glEnable(GL_DEPTH_TEST);
- }
- }
- if(!depth_is_on) {
- glDisable(GL_DEPTH_TEST);
- }
-}
-
-void rad_forcedraw()
-{
- ScrArea *sa, *oldsa;
-
- return; // XXX
-
- oldsa= NULL; // XXX curarea;
-
-/// sa= G.curscreen->areabase.first;
- while(sa) {
- if (sa->spacetype==SPACE_VIEW3D) {
- /* use mywinget() here: othwerwise it draws in header */
-// XXX if(sa->win != mywinget()) areawinset(sa->win);
-// XXX scrarea_do_windraw(sa);
- }
- sa= sa->next;
- }
-// XXX screen_swapbuffers();
-
-// XXX if(oldsa && oldsa!=curarea) areawinset(oldsa->win);
-}
-
diff --git a/source/blender/radiosity/intern/source/radfactors.c b/source/blender/radiosity/intern/source/radfactors.c
deleted file mode 100644
index b87473dd811..00000000000
--- a/source/blender/radiosity/intern/source/radfactors.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- formfactors.c nov/dec 1992
-
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_rand.h"
-
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-#include "RE_render_ext.h" /* for `RE_zbufferall_radio and RE_zbufferall_radio */
-
-/* locals */
-static void rad_setmatrices(RadView *vw);
-static void clearsubflagelem(RNode *rn);
-static void setsubflagelem(RNode *rn);
-
-RadView hemitop, hemiside;
-
-float calcStokefactor(RPatch *shoot, RPatch *rp, RNode *rn, float *area)
-{
- float tvec[3], fac;
- float vec[4][3]; /* vectors of shoot->cent to vertices rp */
- float cross[4][3]; /* cross products of this */
- float rad[4]; /* anlgles between vecs */
-
- /* test for direction */
- VecSubf(tvec, shoot->cent, rp->cent);
- if( tvec[0]*shoot->norm[0]+ tvec[1]*shoot->norm[1]+ tvec[2]*shoot->norm[2]>0.0)
- return 0.0;
-
- if(rp->type==4) {
-
- /* corner vectors */
- VecSubf(vec[0], shoot->cent, rn->v1);
- VecSubf(vec[1], shoot->cent, rn->v2);
- VecSubf(vec[2], shoot->cent, rn->v3);
- VecSubf(vec[3], shoot->cent, rn->v4);
-
- Normalize(vec[0]);
- Normalize(vec[1]);
- Normalize(vec[2]);
- Normalize(vec[3]);
-
- /* cross product */
- Crossf(cross[0], vec[0], vec[1]);
- Crossf(cross[1], vec[1], vec[2]);
- Crossf(cross[2], vec[2], vec[3]);
- Crossf(cross[3], vec[3], vec[0]);
- Normalize(cross[0]);
- Normalize(cross[1]);
- Normalize(cross[2]);
- Normalize(cross[3]);
-
- /* angles */
- rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
- rad[1]= vec[1][0]*vec[2][0]+ vec[1][1]*vec[2][1]+ vec[1][2]*vec[2][2];
- rad[2]= vec[2][0]*vec[3][0]+ vec[2][1]*vec[3][1]+ vec[2][2]*vec[3][2];
- rad[3]= vec[3][0]*vec[0][0]+ vec[3][1]*vec[0][1]+ vec[3][2]*vec[0][2];
-
- rad[0]= acos(rad[0]);
- rad[1]= acos(rad[1]);
- rad[2]= acos(rad[2]);
- rad[3]= acos(rad[3]);
-
- /* Stoke formula */
- VecMulf(cross[0], rad[0]);
- VecMulf(cross[1], rad[1]);
- VecMulf(cross[2], rad[2]);
- VecMulf(cross[3], rad[3]);
-
- VECCOPY(tvec, shoot->norm);
- fac= tvec[0]*cross[0][0]+ tvec[1]*cross[0][1]+ tvec[2]*cross[0][2];
- fac+= tvec[0]*cross[1][0]+ tvec[1]*cross[1][1]+ tvec[2]*cross[1][2];
- fac+= tvec[0]*cross[2][0]+ tvec[1]*cross[2][1]+ tvec[2]*cross[2][2];
- fac+= tvec[0]*cross[3][0]+ tvec[1]*cross[3][1]+ tvec[2]*cross[3][2];
- }
- else {
- /* corner vectors */
- VecSubf(vec[0], shoot->cent, rn->v1);
- VecSubf(vec[1], shoot->cent, rn->v2);
- VecSubf(vec[2], shoot->cent, rn->v3);
-
- Normalize(vec[0]);
- Normalize(vec[1]);
- Normalize(vec[2]);
-
- /* cross product */
- Crossf(cross[0], vec[0], vec[1]);
- Crossf(cross[1], vec[1], vec[2]);
- Crossf(cross[2], vec[2], vec[0]);
- Normalize(cross[0]);
- Normalize(cross[1]);
- Normalize(cross[2]);
-
- /* angles */
- rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
- rad[1]= vec[1][0]*vec[2][0]+ vec[1][1]*vec[2][1]+ vec[1][2]*vec[2][2];
- rad[2]= vec[2][0]*vec[0][0]+ vec[2][1]*vec[0][1]+ vec[2][2]*vec[0][2];
-
- rad[0]= acos(rad[0]);
- rad[1]= acos(rad[1]);
- rad[2]= acos(rad[2]);
-
- /* Stoke formula */
- VecMulf(cross[0], rad[0]);
- VecMulf(cross[1], rad[1]);
- VecMulf(cross[2], rad[2]);
-
- VECCOPY(tvec, shoot->norm);
- fac= tvec[0]*cross[0][0]+ tvec[1]*cross[0][1]+ tvec[2]*cross[0][2];
- fac+= tvec[0]*cross[1][0]+ tvec[1]*cross[1][1]+ tvec[2]*cross[1][2];
- fac+= tvec[0]*cross[2][0]+ tvec[1]*cross[2][1]+ tvec[2]*cross[2][2];
- }
-
- *area= -fac/(2.0*PI);
- return (*area * (shoot->area/rn->area));
-}
-
-
-void calcTopfactors()
-{
- float xsq , ysq, xysq;
- float n;
- float *fp;
- int a, b, hres;
-
- fp = RG.topfactors;
- hres= RG.hemires/2;
- n= hres;
-
- for (a=0; a<hres; a++) {
-
- ysq= (n- ((float)a+0.5))/n;
- ysq*= ysq;
-
- for ( b=0 ; b<hres ; b++ ) {
-
- xsq= ( n-((float)b+ 0.5) )/n;
- xsq*= xsq;
- xysq= xsq+ ysq+ 1.0 ;
- xysq*= xysq;
-
- *fp++ = 1.0/(xysq* PI* n*n);
- }
- }
-
-}
-
-void calcSidefactors()
-{
- float xsq , ysq, xysq;
- float n, y;
- float *fp;
- int a, b, hres;
-
- fp = RG.sidefactors;
- hres= RG.hemires/2;
- n= hres;
-
- for (a=0; a<hres; a++) {
-
- y= (n- ((float)a+0.5))/n;
- ysq= y*y;
-
- for ( b=0 ; b<hres ; b++ ) {
-
- xsq= ( n-((float)b+ 0.5) )/n;
- xsq*= xsq;
- xysq= xsq+ ysq+ 1.0 ;
- xysq*= xysq;
-
- *fp++ = y/(xysq* PI* n*n);
- }
- }
-
-}
-
-
-void initradiosity()
-{
- /* allocates and makes LUTs for top/side factors */
- /* allocates and makes index array */
- int a, hres2;
-
- if(RG.topfactors) MEM_freeN(RG.topfactors);
- if(RG.sidefactors) MEM_freeN(RG.sidefactors);
- if(RG.index) MEM_freeN(RG.index);
-
- RG.topfactors= MEM_callocN(RG.hemires*RG.hemires, "initradiosity");
- calcTopfactors();
- RG.sidefactors= MEM_callocN(RG.hemires*RG.hemires, "initradiosity1");
- calcSidefactors();
-
- RG.index= MEM_callocN(4*RG.hemires, "initradiosity3");
- hres2= RG.hemires/2;
- for(a=0; a<RG.hemires; a++) {
- RG.index[a]= a<hres2 ? a: (hres2-1-( a % hres2 ));
- }
-
-}
-
-void rad_make_hocos(RadView *vw)
-{
- /* float hoco[4]; */
- /* int a; */
-
- /* for(a=0; a< R.totvert;a++) { */
- /* projectvert(vec, ver->ho); */
- /* ver->clip = testclip(ver->ho); */
-/* */
- /* } */
-}
-
-static void rad_setmatrices(RadView *vw) /* for hemi's */
-{
- float up1[3], len, twist;
-
- i_lookat(vw->cam[0], vw->cam[1], vw->cam[2], vw->tar[0], vw->tar[1], vw->tar[2], 0, vw->viewmat);
- up1[0] = vw->viewmat[0][0]*vw->up[0] + vw->viewmat[1][0]*vw->up[1] + vw->viewmat[2][0]*vw->up[2];
- up1[1] = vw->viewmat[0][1]*vw->up[0] + vw->viewmat[1][1]*vw->up[1] + vw->viewmat[2][1]*vw->up[2];
- up1[2] = vw->viewmat[0][2]*vw->up[0] + vw->viewmat[1][2]*vw->up[1] + vw->viewmat[2][2]*vw->up[2];
-
- len= up1[0]*up1[0]+up1[1]*up1[1];
- if(len>0.0) {
- twist= -atan2(up1[0], up1[1]);
- }
- else twist= 0.0;
-
- i_lookat(vw->cam[0], vw->cam[1], vw->cam[2], vw->tar[0], vw->tar[1], vw->tar[2], (180.0*twist/M_PI), vw->viewmat);
-
- /* window matrix was set in inithemiwindows */
-
-}
-
-
-void hemizbuf(RadView *vw)
-{
- float *factors;
- unsigned int *rz;
- int a, b, inda, hres;
-
- rad_setmatrices(vw);
- 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;
- else factors= RG.sidefactors;
- hres= RG.hemires/2;
-
- rz= vw->rect;
- for(a=0; a<vw->recty; a++) {
- inda= hres*RG.index[a];
- for(b=0; b<vw->rectx; b++, rz++) {
- if(*rz<RG.totelem) {
- RG.formfactors[*rz]+= factors[inda+RG.index[b]];
- }
- }
- }
-}
-
-int makeformfactors(RPatch *shoot)
-{
- RNode **re;
- float len, vec[3], up[3], side[3], tar[5][3], *fp;
- int a=0, overfl;
-
- if(RG.totelem==0) return 0;
-
- memset(RG.formfactors, 0, 4*RG.totelem);
-
- /* set up hemiview */
- /* first: random upvector */
- do {
- a++;
- vec[0]= (float)BLI_drand();
- vec[1]= (float)BLI_drand();
- vec[2]= (float)BLI_drand();
- Crossf(up, shoot->norm, vec);
- len= Normalize(up);
- /* this safety for input normals that are zero or illegal sized */
- if(a>3) return 0;
- } while(len==0.0 || len>1.0);
-
- VECCOPY(hemitop.up, up);
- VECCOPY(hemiside.up, shoot->norm);
-
- Crossf(side, shoot->norm, up);
-
- /* five targets */
- VecAddf(tar[0], shoot->cent, shoot->norm);
- VecAddf(tar[1], shoot->cent, up);
- VecSubf(tar[2], shoot->cent, up);
- VecAddf(tar[3], shoot->cent, side);
- VecSubf(tar[4], shoot->cent, side);
-
- /* camera */
- VECCOPY(hemiside.cam, shoot->cent);
- VECCOPY(hemitop.cam, shoot->cent);
-
- /* do it! */
- VECCOPY(hemitop.tar, tar[0]);
- hemizbuf(&hemitop);
-
- for(a=1; a<5; a++) {
- VECCOPY(hemiside.tar, tar[a]);
- hemizbuf(&hemiside);
- }
-
- /* convert factors to real radiosity */
- re= RG.elem;
- fp= RG.formfactors;
-
- overfl= 0;
- for(a= RG.totelem; a>0; a--, re++, fp++) {
-
- if(*fp!=0.0) {
-
- *fp *= shoot->area/(*re)->area;
-
- if(*fp>1.0) {
- overfl= 1;
- *fp= 1.0001;
- }
- }
- }
-
- if(overfl) {
- if(shoot->first->down1) {
- splitpatch(shoot);
- return 0;
- }
- }
-
- return 1;
-}
-
-void applyformfactors(RPatch *shoot)
-{
- RPatch *rp;
- RNode **el, *rn;
- float *fp, *ref, unr, ung, unb, r, g, b, w;
- int a;
-
- unr= shoot->unshot[0];
- ung= shoot->unshot[1];
- unb= shoot->unshot[2];
-
- fp= RG.formfactors;
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++, fp++) {
- rn= *el;
- if(*fp!= 0.0) {
- rp= rn->par;
- ref= rp->ref;
-
- r= (*fp)*unr*ref[0];
- g= (*fp)*ung*ref[1];
- b= (*fp)*unb*ref[2];
-
- w= rn->area/rp->area;
- rn->totrad[0]+= r;
- rn->totrad[1]+= g;
- rn->totrad[2]+= b;
-
- rp->unshot[0]+= w*r;
- rp->unshot[1]+= w*g;
- rp->unshot[2]+= w*b;
- }
- }
-
- shoot->unshot[0]= shoot->unshot[1]= shoot->unshot[2]= 0.0;
-}
-
-RPatch *findshootpatch()
-{
- RPatch *rp, *shoot;
- float energy, maxenergy;
-
- shoot= 0;
- maxenergy= 0.0;
- rp= RG.patchbase.first;
- while(rp) {
- energy= rp->unshot[0]*rp->area;
- energy+= rp->unshot[1]*rp->area;
- energy+= rp->unshot[2]*rp->area;
-
- if(energy>maxenergy) {
- shoot= rp;
- maxenergy= energy;
- }
- rp= rp->next;
- }
-
- if(shoot) {
- maxenergy/= RG.totenergy;
- if(maxenergy<RG.convergence) return 0;
- }
-
- return shoot;
-}
-
-void setnodeflags(RNode *rn, int flag, int set)
-{
-
- if(rn->down1) {
- setnodeflags(rn->down1, flag, set);
- setnodeflags(rn->down2, flag, set);
- }
- else {
- if(set) rn->f |= flag;
- else rn->f &= ~flag;
- }
-}
-
-void backface_test(RPatch *shoot)
-{
- RPatch *rp;
- float tvec[3];
-
- rp= RG.patchbase.first;
- while(rp) {
- if(rp!=shoot) {
-
- VecSubf(tvec, shoot->cent, rp->cent);
- if( tvec[0]*rp->norm[0]+ tvec[1]*rp->norm[1]+ tvec[2]*rp->norm[2]<0.0) {
- setnodeflags(rp->first, RAD_BACKFACE, 1);
- }
- }
- rp= rp->next;
- }
-}
-
-void clear_backface_test()
-{
- RNode **re;
- int a;
-
- re= RG.elem;
- for(a= RG.totelem-1; a>=0; a--, re++) {
- (*re)->f &= ~RAD_BACKFACE;
- }
-
-}
-
-void rad_init_energy()
-{
- /* call before shooting */
- /* keep patches and elements, clear all data */
- RNode **el, *rn;
- RPatch *rp;
- int a;
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- VECCOPY(rn->totrad, rn->par->emit);
- }
-
- RG.totenergy= 0.0;
- rp= RG.patchbase.first;
- while(rp) {
- VECCOPY(rp->unshot, rp->emit);
-
- RG.totenergy+= rp->unshot[0]*rp->area;
- RG.totenergy+= rp->unshot[1]*rp->area;
- RG.totenergy+= rp->unshot[2]*rp->area;
-
- rp->f= 0;
-
- rp= rp->next;
- }
-}
-
-void progressiverad()
-{
- RPatch *shoot;
- float unshot[3];
- int it= 0;
-
- rad_printstatus();
- rad_init_energy();
-
- shoot=findshootpatch();
-
- while( shoot ) {
-
- setnodeflags(shoot->first, RAD_SHOOT, 1);
-
- backface_test(shoot);
-
- drawpatch_ext(shoot, 0x88FF00);
-
- if(shoot->first->f & RAD_TWOSIDED) {
- VECCOPY(unshot, shoot->unshot);
- VecNegf(shoot->norm);
- if(makeformfactors(shoot))
- applyformfactors(shoot);
- VecNegf(shoot->norm);
- VECCOPY(shoot->unshot, unshot);
- }
-
- if( makeformfactors(shoot) ) {
- applyformfactors(shoot);
-
- it++;
- //XXX set_timecursor(it);
- if( (it & 3)==1 ) {
- make_node_display();
- rad_forcedraw();
- }
- setnodeflags(shoot->first, RAD_SHOOT, 0);
- }
-
- clear_backface_test();
-
- //XXX if(blender_test_break()) break;
- if(RG.maxiter && RG.maxiter<=it) break;
-
- shoot=findshootpatch();
-
- }
-
-}
-
-
-/* ************* subdivideshoot *********** */
-
-void minmaxradelem(RNode *rn, float *min, float *max)
-{
- int c;
-
- if(rn->down1) {
- minmaxradelem(rn->down1, min, max);
- minmaxradelem(rn->down2, min, max);
- }
- else {
- for(c=0; c<3; c++) {
- min[c]= MIN2(min[c], rn->totrad[c]);
- max[c]= MAX2(max[c], rn->totrad[c]);
- }
- }
-}
-
-void minmaxradelemfilt(RNode *rn, float *min, float *max, float *errmin, float *errmax)
-{
- float col[3], area;
- int c;
-
- if(rn->down1) {
- minmaxradelemfilt(rn->down1, min, max, errmin, errmax);
- minmaxradelemfilt(rn->down2, min, max, errmin, errmax);
- }
- else {
- VECCOPY(col, rn->totrad);
-
- for(c=0; c<3; c++) {
- min[c]= MIN2(min[c], col[c]);
- max[c]= MAX2(max[c], col[c]);
- }
-
- VecMulf(col, 2.0);
- area= 2.0;
- if(rn->ed1) {
- VecAddf(col, rn->ed1->totrad, col);
- area+= 1.0;
- }
- if(rn->ed2) {
- VecAddf(col, rn->ed2->totrad, col);
- area+= 1.0;
- }
- if(rn->ed3) {
- VecAddf(col, rn->ed3->totrad, col);
- area+= 1.0;
- }
- if(rn->ed4) {
- VecAddf(col, rn->ed4->totrad, col);
- area+= 1.0;
- }
- VecMulf(col, 1.0/area);
-
- for(c=0; c<3; c++) {
- errmin[c]= MIN2(errmin[c], col[c]);
- errmax[c]= MAX2(errmax[c], col[c]);
- }
- }
-}
-
-static void setsubflagelem(RNode *rn)
-{
-
- if(rn->down1) {
- setsubflagelem(rn->down1);
- setsubflagelem(rn->down2);
- }
- else {
- rn->f |= RAD_SUBDIV;
- }
-}
-
-static void clearsubflagelem(RNode *rn)
-{
-
- if(rn->down1) {
- setsubflagelem(rn->down1);
- setsubflagelem(rn->down2);
- }
- else {
- rn->f &= ~RAD_SUBDIV;
- }
-}
-
-void subdivideshootElements(int it)
-{
- RPatch *rp, *shoot;
- RNode **el, *rn;
- float *fp, err, stoke, area, min[3], max[3], errmin[3], errmax[3];
- int a, b, c, d, e, f, contin;
- int maxlamp;
-
- if(RG.maxsublamp==0) maxlamp= RG.totlamp;
- else maxlamp= RG.maxsublamp;
-
- while(it) {
- rad_printstatus();
- rad_init_energy();
- it--;
-
- for(a=0; a<maxlamp; a++) {
- shoot= findshootpatch();
- if(shoot==0) break;
-
- //XXX set_timecursor(a);
- drawpatch_ext(shoot, 0x88FF00);
-
- setnodeflags(shoot->first, RAD_SHOOT, 1);
- if( makeformfactors(shoot) ) {
-
- fp= RG.formfactors;
- el= RG.elem;
- for(b=RG.totelem; b>0; b--, el++) {
- rn= *el;
-
- if( (rn->f & RAD_SUBDIV)==0 && *fp!=0.0) {
- if(rn->par->emit[0]+rn->par->emit[1]+rn->par->emit[2]==0.0) {
-
- stoke= calcStokefactor(shoot, rn->par, rn, &area);
- if(stoke!= 0.0) {
-
- err= *fp/stoke;
-
- /* area error */
- area*=(0.5*RG.hemires*RG.hemires);
-
- if(area>35.0) {
- if(err<0.95 || err>1.05) {
- if(err>0.05) {
- rn->f |= RAD_SUBDIV;
- rn->par->f |= RAD_SUBDIV;
- }
- }
- }
- }
-
- }
- }
-
- fp++;
-
- }
-
- applyformfactors(shoot);
-
- if( (a & 3)==1 ) {
- make_node_display();
- rad_forcedraw();
- }
-
- setnodeflags(shoot->first, RAD_SHOOT, 0);
- }
- else a--;
-
- //XXX if(blender_test_break()) break;
- }
-
- /* test for extreme small color change within a patch with subdivflag */
-
- rp= RG.patchbase.first;
-
- while(rp) {
- if(rp->f & RAD_SUBDIV) { /* rp has elems that need subdiv */
- /* at least 4 levels deep */
- rn= rp->first->down1;
- if(rn) {
- rn= rn->down1;
- if(rn) {
- rn= rn->down1;
- if(rn) rn= rn->down1;
- }
- }
- if(rn) {
- INIT_MINMAX(min, max);
- /* errmin and max are the filtered colors */
- INIT_MINMAX(errmin, errmax);
- minmaxradelemfilt(rp->first, min, max, errmin, errmax);
-
- /* if small difference between colors: no subdiv */
- /* also test for the filtered ones: but with higher critical level */
-
- contin= 0;
- a= abs( calculatecolor(min[0])-calculatecolor(max[0]));
- b= abs( calculatecolor(errmin[0])-calculatecolor(errmax[0]));
- if(a<15 || b<7) {
- c= abs( calculatecolor(min[1])-calculatecolor(max[1]));
- d= abs( calculatecolor(errmin[1])-calculatecolor(errmax[1]));
- if(c<15 || d<7) {
- e= abs( calculatecolor(min[2])-calculatecolor(max[2]));
- f= abs( calculatecolor(errmin[2])-calculatecolor(errmax[2]));
- if(e<15 || f<7) {
- contin= 1;
- clearsubflagelem(rp->first);
- /* printf("%d %d %d %d %d %d\n", a, b, c, d, e, f); */
- }
- }
- }
- if(contin) {
- drawpatch_ext(rp, 0xFFFF);
- }
- }
- }
- rp->f &= ~RAD_SUBDIV;
- rp= rp->next;
- }
-
- contin= 0;
-
- el= RG.elem;
- for(b=RG.totelem; b>0; b--, el++) {
- rn= *el;
- if(rn->f & RAD_SUBDIV) {
- rn->f-= RAD_SUBDIV;
- subdivideNode(rn, 0);
- if(rn->down1) {
- subdivideNode(rn->down1, 0);
- subdivideNode(rn->down2, 0);
- contin= 1;
- }
- }
- }
- makeGlobalElemArray();
-
- //XXX if(contin==0 || blender_test_break()) break;
- }
-
- make_node_display();
-}
-
-void subdivideshootPatches(int it)
-{
- RPatch *rp, *shoot, *next;
- float *fp, err, stoke, area;
- int a, contin;
- int maxlamp;
-
- if(RG.maxsublamp==0) maxlamp= RG.totlamp;
- else maxlamp= RG.maxsublamp;
-
- while(it) {
- rad_printstatus();
- rad_init_energy();
- it--;
-
- for(a=0; a<maxlamp; a++) {
- shoot= findshootpatch();
- if(shoot==0) break;
-
- //XXX set_timecursor(a);
- drawpatch_ext(shoot, 0x88FF00);
-
- setnodeflags(shoot->first, RAD_SHOOT, 1);
-
- if( makeformfactors(shoot) ) {
-
- fp= RG.formfactors;
- rp= RG.patchbase.first;
- while(rp) {
- if(*fp!=0.0 && rp!=shoot) {
-
- stoke= calcStokefactor(shoot, rp, rp->first, &area);
- if(stoke!= 0.0) {
- if(area>.1) { /* does patch receive more than (about)10% of energy? */
- rp->f= RAD_SUBDIV;
- }
- else {
-
- err= *fp/stoke;
-
- /* area error */
- area*=(0.5*RG.hemires*RG.hemires);
-
- if(area>45.0) {
- if(err<0.95 || err>1.05) {
- if(err>0.05) {
-
- rp->f= RAD_SUBDIV;
-
- }
- }
- }
- }
- }
- }
- fp++;
-
- rp= rp->next;
- }
-
- applyformfactors(shoot);
-
- if( (a & 3)==1 ) {
- make_node_display();
- rad_forcedraw();
- }
-
- setnodeflags(shoot->first, RAD_SHOOT, 0);
-
- //XXX if(blender_test_break()) break;
- }
- else a--;
-
- }
-
- contin= 0;
-
- rp= RG.patchbase.first;
- while(rp) {
- next= rp->next;
- if(rp->f & RAD_SUBDIV) {
- if(rp->emit[0]+rp->emit[1]+rp->emit[2]==0.0) {
- contin= 1;
- subdivideNode(rp->first, 0);
- if(rp->first->down1) {
- subdivideNode(rp->first->down1, 0);
- subdivideNode(rp->first->down2, 0);
- }
- }
- }
- rp= next;
- }
-
- converttopatches();
- makeGlobalElemArray();
-
- //XXX if(contin==0 || blender_test_break()) break;
- }
- make_node_display();
-}
-
-void inithemiwindows()
-{
- RadView *vw;
-
- /* the hemiwindows */
- vw= &(hemitop);
- memset(vw, 0, sizeof(RadView));
- vw->rectx= RG.hemires;
- vw->recty= RG.hemires;
- vw->rectz= MEM_mallocN(sizeof(int)*vw->rectx*vw->recty, "initwindows");
- vw->rect= MEM_mallocN(sizeof(int)*vw->rectx*vw->recty, "initwindows");
- vw->mynear= RG.maxsize/2000.0;
- vw->myfar= 2.0*RG.maxsize;
- vw->wx1= -vw->mynear;
- vw->wx2= vw->mynear;
- vw->wy1= -vw->mynear;
- vw->wy2= vw->mynear;
-
- i_window(vw->wx1, vw->wx2, vw->wy1, vw->wy2, vw->mynear, vw->myfar, vw->winmat);
-
- hemiside= hemitop;
-
- vw= &(hemiside);
- vw->recty/= 2;
- vw->wy1= vw->wy2;
- vw->wy2= 0.0;
-
- i_window(vw->wx1, vw->wx2, vw->wy1, vw->wy2, vw->mynear, vw->myfar, vw->winmat);
-
-}
-
-void closehemiwindows()
-{
-
- if(hemiside.rect) MEM_freeN(hemiside.rect);
- if(hemiside.rectz) MEM_freeN(hemiside.rectz);
- hemiside.rectz= 0;
- hemiside.rect= 0;
- hemitop.rectz= 0;
- hemitop.rect= 0;
-}
diff --git a/source/blender/radiosity/intern/source/radio.c b/source/blender/radiosity/intern/source/radio.c
deleted file mode 100644
index 63032b2d603..00000000000
--- a/source/blender/radiosity/intern/source/radio.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- radio.c nov/dec 1992
- may 1999
-
- $Id$
-
- - mainloop
- - interactivity
-
-
- - PREPROCES
- - collect meshes
- - spitconnected (all faces with different color and normals)
- - setedgepointers (nodes pointing to neighbours)
-
- - EDITING
- - min-max patch en min-max element size
- - using this info patches subdividing
- - lamp subdivide
-
- - if there are too many lamps for subdivide shooting:
- - temporal join patches
-
- - SUBDIVIDE SHOOTING
- - except for last shooting, this defines patch subdivide
- - if subdivided patches still > 2*minsize : continue
- - at the end create as many elements as possible
- - als store if lamp (can still) cause subdivide.
-
- - REFINEMENT SHOOTING
- - test for overflows (shootpatch subdivide)
- - testen for extreme color transitions:
- - if possible: shootpatch subdivide
- - elements subdivide = start over ?
- - continue itterate until ?
-
- - DEFINITIVE SHOOTING
- - user indicates how many faces maximum and duration of itteration.
-
- - POST PROCESS
- - join element- nodes when nothing happens in it (filter nodes, filter faces)
- - define gamma & mul
-
- *************************************** */
-
-#include <math.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-#include "PIL_time.h"
-
-#include "BLI_blenlib.h"
-
-#include "DNA_object_types.h"
-#include "DNA_radio_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* locals? This one was already done in radio.h... */
-/* void rad_status_str(char *str); */
-
-RadGlobal RG= {0, 0};
-
-void freeAllRad(Scene *scene)
-{
- Base *base;
- extern int Ntotvert, Ntotnode, Ntotpatch;
-
- /* clear flag that disables drawing the meshes */
- if(scene) {
- base= (scene->base.first);
- while(base) {
- if(base->object->type==OB_MESH) {
- base->flag &= ~OB_RADIO;
- }
- base= base->next;
- }
- }
-
- free_fastAll(); /* verts, nodes, patches */
- RG.patchbase.first= RG.patchbase.last= 0;
- Ntotvert= Ntotnode= Ntotpatch= 0;
-
- closehemiwindows(); /* not real windows anymore... */
- if(RG.elem) MEM_freeN(RG.elem);
- RG.elem= 0;
- if(RG.verts) MEM_freeN(RG.verts);
- RG.verts= 0;
- if(RG.topfactors) MEM_freeN(RG.topfactors);
- RG.topfactors= 0;
- if(RG.sidefactors) MEM_freeN(RG.sidefactors);
- RG.sidefactors= 0;
- if(RG.formfactors) MEM_freeN(RG.formfactors);
- RG.formfactors= 0;
- if(RG.index) MEM_freeN(RG.index);
- RG.index= 0;
- if(RG.facebase) {
- init_face_tab(); /* frees all tables */
- MEM_freeN(RG.facebase);
- RG.facebase= 0;
- }
-
- if(RG.mfdata) {
- CustomData_free(RG.mfdata, RG.mfdatatot);
- MEM_freeN(RG.mfdata);
- MEM_freeN(RG.mfdatanodes);
- RG.mfdatanodes= NULL;
- RG.mfdata= NULL;
- RG.mfdatatot= 0;
- }
- RG.totelem= RG.totpatch= RG.totvert= RG.totface= RG.totlamp= RG.totmat= 0;
-}
-
-int rad_phase()
-{
- int flag= 0;
-
- if(RG.totpatch) flag |= RAD_PHASE_PATCHES;
- if(RG.totface) flag |= RAD_PHASE_FACES;
-
- return flag;
-}
-
-void rad_status_str(char *str)
-{
- extern int totfastmem;
- int tot;
- char *phase;
-
- tot= (RG.totface*sizeof(Face))/1024;
- tot+= totfastmem/1024;
-
- if(RG.phase==RAD_SHOOTE) phase= "Phase: ELEMENT SUBD, ";
- else if(RG.phase==RAD_SHOOTP) phase= "Phase: PATCH SUBD, ";
- else if(RG.phase==RAD_SOLVE) phase= "Phase: SOLVE, ";
- else if(RG.totpatch==0) phase= "Phase: COLLECT MESHES ";
- else if(RG.totface) phase= "Phase: FINISHED, ";
- else phase= "Phase: INIT, ";
-
- if(RG.totpatch==0) strcpy(str, phase);
- else sprintf(str, "%s TotPatch: %d TotElem: %d Emit: %d Faces %d Mem: %d k ", phase, RG.totpatch, RG.totelem, RG.totlamp, RG.totface, tot);
-
- if(RG.phase==RAD_SOLVE) strcat(str, "(press ESC to stop)");
-}
-
-void rad_printstatus()
-{
- /* actions always are started from a buttonswindow */
-// XX if(curarea) {
-// scrarea_do_windraw(curarea);
-// screen_swapbuffers();
-// }
-}
-
-void rad_setlimits(Scene *scene)
-{
- Radio *rad= scene->radio;
- float fac;
-
- fac= 0.0005*rad->pama;
- RG.patchmax= RG.maxsize*fac;
- RG.patchmax*= RG.patchmax;
- fac= 0.0005*rad->pami;
- RG.patchmin= RG.maxsize*fac;
- RG.patchmin*= RG.patchmin;
-
- fac= 0.0005*rad->elma;
- RG.elemmax= RG.maxsize*fac;
- RG.elemmax*= RG.elemmax;
- fac= 0.0005*rad->elmi;
- RG.elemmin= RG.maxsize*fac;
- RG.elemmin*= RG.elemmin;
-}
-
-void set_radglobal(Scene *scene)
-{
- /* always call before any action is performed */
- Radio *rad= scene->radio;
-
- if(RG.radio==0) {
- /* firsttime and to be sure */
- memset(&RG, 0, sizeof(RadGlobal));
- }
-
- if(rad==0) return;
-
- if(rad != RG.radio) {
- if(RG.radio) freeAllRad(scene);
- memset(&RG, 0, sizeof(RadGlobal));
- RG.radio= rad;
- }
-
- RG.hemires= rad->hemires & 0xFFF0;
- RG.drawtype= rad->drawtype;
- RG.flag= rad->flag;
- RG.subshootp= rad->subshootp;
- RG.subshoote= rad->subshoote;
- RG.nodelim= rad->nodelim;
- RG.maxsublamp= rad->maxsublamp;
- RG.maxnode= 2*rad->maxnode; /* in button:max elem, subdividing! */
- RG.convergence= rad->convergence/1000.0;
- RG.radfac= rad->radfac;
- RG.gamma= rad->gamma;
- RG.maxiter= rad->maxiter;
-
- RG.re= NULL; /* struct render, for when call it from render engine */
-
- rad_setlimits(scene);
-}
-
-/* called from buttons.c */
-void add_radio(Scene *scene)
-{
- Radio *rad;
-
- if(scene->radio) MEM_freeN(scene->radio);
- rad= scene->radio= MEM_callocN(sizeof(Radio), "radio");
-
- rad->hemires= 300;
- rad->convergence= 0.1;
- rad->radfac= 30.0;
- rad->gamma= 2.0;
- rad->drawtype= RAD_SOLID;
- rad->subshootp= 1;
- rad->subshoote= 2;
- rad->maxsublamp= 0;
-
- rad->pama= 500;
- rad->pami= 200;
- rad->elma= 100;
- rad->elmi= 20;
- rad->nodelim= 0;
- rad->maxnode= 10000;
- rad->maxiter= 120; // arbitrary
- rad->flag= 2;
- set_radglobal(scene);
-}
-
-void delete_radio(Scene *scene)
-{
- freeAllRad(scene);
- if(scene->radio) MEM_freeN(scene->radio);
- scene->radio= 0;
-
- RG.radio= 0;
-}
-
-int rad_go(Scene *scene) /* return 0 when user escapes */
-{
- double stime= PIL_check_seconds_timer();
- int retval;
-
- if(RG.totface) return 0;
-
- G.afbreek= 0;
-
- set_radglobal(scene);
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views */
-
- maxsizePatches();
-
- setnodelimit(RG.patchmin);
- RG.phase= RAD_SHOOTP;
- subdivideshootPatches(RG.subshootp);
-
- setnodelimit(RG.elemmin);
- RG.phase= RAD_SHOOTE;
- subdivideshootElements(RG.subshoote);
-
- setnodelimit(RG.patchmin);
- subdividelamps();
-
- setnodelimit(RG.elemmin);
-
- RG.phase= RAD_SOLVE;
- subdiv_elements();
-
- progressiverad();
-
- removeEqualNodes(RG.nodelim);
-
- make_face_tab(); /* now anchored */
-
- closehemiwindows();
- RG.phase= 0;
-
- stime= PIL_check_seconds_timer()-stime;
- printf("Radiosity solving time: %dms\n", (int) (stime*1000));
-
- if(G.afbreek==1) retval= 1;
- else retval= 0;
-
- G.afbreek= 0;
-
- return retval;
-}
-
-void rad_subdivshootpatch(Scene *scene)
-{
-
- if(RG.totface) return;
-
- G.afbreek= 0;
-
- set_radglobal(scene);
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views */
-
- subdivideshootPatches(1);
-
- removeEqualNodes(RG.nodelim);
- closehemiwindows();
-
-// XXX allqueue(REDRAWVIEW3D, 1);
-}
-
-void rad_subdivshootelem(Scene *scene)
-{
-
- if(RG.totface) return;
-
- G.afbreek= 0;
-
- set_radglobal(scene);
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views */
-
- subdivideshootElements(1);
-
- removeEqualNodes(RG.nodelim);
- closehemiwindows();
-
-// XXX allqueue(REDRAWVIEW3D, 1);
-}
-
-void rad_limit_subdivide(Scene *scene)
-{
-
- if(scene->radio==0) return;
-
- set_radglobal(scene);
-
- if(RG.totpatch==0) {
- /* printf("exit: no relevant data\n"); */
- return;
- }
-
- maxsizePatches();
-
- init_face_tab(); /* free faces */
-}
diff --git a/source/blender/radiosity/intern/source/radnode.c b/source/blender/radiosity/intern/source/radnode.c
deleted file mode 100644
index fa23ca5da57..00000000000
--- a/source/blender/radiosity/intern/source/radnode.c
+++ /dev/null
@@ -1,1103 +0,0 @@
-/* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- node.c nov/dec 1992
- may 1999
-
- $Id$
-
- *************************************** */
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-
-#include "BLO_sys_types.h" // for intptr_t support
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* locals */
-static void *malloc_fast(int size);
-static void *calloc_fast(int size);
-static void free_fast(void *poin, int siz);
-static void deleteTriNodes(RNode *node);
-/* lower because of local type define */
-/* void check_mallocgroup(MallocGroup *mg); */
-
-
-/* ********** fastmalloc ************** */
-
-#define MAL_GROUPSIZE 256
-#define MAL_AVAILABLE 1
-#define MAL_FULL 2
-
-
-
-
-ListBase MallocBase= {0, 0};
-int totfastmem= 0;
-
-typedef struct MallocGroup {
- struct MallocGroup *next, *prev;
- short size, flag;
- short curfree, tot;
- char flags[MAL_GROUPSIZE];
- char *data;
-} MallocGroup;
-
-/* one more local */
-void check_mallocgroup(MallocGroup *mg);
-
-void check_mallocgroup(MallocGroup *mg)
-{
- int a;
- char *cp;
-
- if(mg->tot==MAL_GROUPSIZE) {
- mg->flag= MAL_FULL;
- return;
- }
-
- cp= mg->flags;
-
- if(mg->curfree<MAL_GROUPSIZE-1) {
- if(cp[mg->curfree+1]==0) {
- mg->curfree++;
- return;
- }
- }
- if(mg->curfree>0) {
- if(cp[mg->curfree-1]==0) {
- mg->curfree--;
- return;
- }
- }
-
- for(a=0; a<MAL_GROUPSIZE; a++) {
- if(cp[a]==0) {
- mg->curfree= a;
- return;
- }
- }
- printf("fastmalloc: shouldnt be here\n");
-}
-
-static void *malloc_fast(int size)
-{
- MallocGroup *mg;
- void *retval;
-
- mg= MallocBase.last;
- while(mg) {
- if(mg->size==size) {
- if(mg->flag & MAL_AVAILABLE) {
- mg->flags[mg->curfree]= 1;
- mg->tot++;
- retval= mg->data+mg->curfree*mg->size;
- check_mallocgroup(mg);
- return retval;
- }
- }
- mg= mg->prev;
- }
-
- /* no free block found */
- mg= MEM_callocN(sizeof(MallocGroup), "mallocgroup");
- BLI_addtail(&MallocBase, mg);
- mg->data= MEM_mallocN(MAL_GROUPSIZE*size, "mallocgroupdata");
- mg->flag= MAL_AVAILABLE;
- mg->flags[0]= 1;
- mg->curfree= 1;
- mg->size= size;
- mg->tot= 1;
-
- totfastmem+= sizeof(MallocGroup)+MAL_GROUPSIZE*size;
-
- return mg->data;
-}
-
-static void *calloc_fast(int size)
-{
- void *poin;
-
- poin= malloc_fast(size);
- memset(poin, 0, size);
-
- return poin;
-}
-
-static void free_fast(void *poin, int size)
-{
- MallocGroup *mg;
- intptr_t val;
-
- mg= MallocBase.last;
- while(mg) {
- if(mg->size==size) {
- if( ((intptr_t)poin) >= ((intptr_t)mg->data) ) {
- if( ((intptr_t)poin) < ((intptr_t)(mg->data+MAL_GROUPSIZE*size)) ) {
- val= ((intptr_t)poin) - ((intptr_t)mg->data);
- val/= size;
- mg->curfree= val;
- mg->flags[val]= 0;
- mg->flag= MAL_AVAILABLE;
-
- mg->tot--;
- if(mg->tot==0) {
- BLI_remlink(&MallocBase, mg);
- MEM_freeN(mg->data);
- MEM_freeN(mg);
- totfastmem-= sizeof(MallocGroup)+MAL_GROUPSIZE*size;
- }
- return;
- }
- }
- }
- mg= mg->prev;
- }
- printf("fast free: pointer not in memlist %p size %d\n",
- poin, size);
-}
-
-/* security: only one function in a time can use it */
-static char *fastmallocstr= 0;
-
-void free_fastAll()
-{
- MallocGroup *mg;
-
- mg= MallocBase.first;
- while(mg) {
- BLI_remlink(&MallocBase, mg);
- MEM_freeN(mg->data);
- MEM_freeN(mg);
- mg= MallocBase.first;
- }
- totfastmem= 0;
- fastmallocstr= 0;
-}
-
-void start_fastmalloc(char *str)
-{
- if(fastmallocstr) {
-// XXX error("Fastmalloc in use: %s", fastmallocstr);
- return;
- }
- fastmallocstr= str;
-}
-
-/* **************************************** */
-
-float nodelimit;
-
-void setnodelimit(float limit)
-{
- nodelimit= limit;
-
-}
-
-/* ************ memory management *********** */
-
-int Ntotvert=0, Ntotnode=0, Ntotpatch=0;
-
-float *mallocVert()
-{
- Ntotvert++;
- return (float *)malloc_fast(16);
-}
-
-float *callocVert()
-{
- Ntotvert++;
- return (float *)calloc_fast(16);
-}
-
-void freeVert(float *vert)
-{
- free_fast(vert, 16);
- Ntotvert--;
-}
-
-int totalRadVert()
-{
- return Ntotvert;
-}
-
-RNode *mallocNode()
-{
- Ntotnode++;
- return (RNode *)malloc_fast(sizeof(RNode));
-}
-
-RNode *callocNode()
-{
- Ntotnode++;
- return (RNode *)calloc_fast(sizeof(RNode));
-}
-
-void freeNode(RNode *node)
-{
- free_fast(node, sizeof(RNode));
- Ntotnode--;
-}
-
-void freeNode_recurs(RNode *node)
-{
-
- if(node->down1) {
- freeNode_recurs(node->down1);
- freeNode_recurs(node->down2);
- }
-
- node->down1= node->down2= 0;
- freeNode(node);
-
-}
-
-RPatch *mallocPatch()
-{
- Ntotpatch++;
- return (RPatch *)malloc_fast(sizeof(RPatch));
-}
-
-RPatch *callocPatch()
-{
- Ntotpatch++;
- return (RPatch *)calloc_fast(sizeof(RPatch));
-}
-
-void freePatch(RPatch *patch)
-{
- free_fast(patch, sizeof(RPatch));
- Ntotpatch--;
-}
-
-/* ************ SUBDIVIDE *********** */
-
-
-void replaceAllNode(RNode *neighb, RNode *newn)
-{
- /* changes from all neighbours the edgepointers that point to newn->up in new */
- int ok= 0;
-
-
- if(neighb==0) return;
- if(newn->up==0) return;
-
- if(neighb->ed1==newn->up) {
- neighb->ed1= newn;
- ok= 1;
- }
- else if(neighb->ed2==newn->up) {
- neighb->ed2= newn;
- ok= 1;
- }
- else if(neighb->ed3==newn->up) {
- neighb->ed3= newn;
- ok= 1;
- }
- else if(neighb->ed4==newn->up) {
- neighb->ed4= newn;
- ok= 1;
- }
-
- if(ok && neighb->down1) {
- replaceAllNode(neighb->down1, newn);
- replaceAllNode(neighb->down2, newn);
- }
-}
-
-void replaceAllNodeInv(RNode *neighb, RNode *old)
-{
- /* changes from all neighbours the edgepointers that point to old in old->up */
- if(neighb==0) return;
- if(old->up==0) return;
-
- if(neighb->ed1==old) {
- neighb->ed1= old->up;
- }
- else if(neighb->ed2==old) {
- neighb->ed2= old->up;
- }
- else if(neighb->ed3==old) {
- neighb->ed3= old->up;
- }
- else if(neighb->ed4==old) {
- neighb->ed4= old->up;
- }
-
- if(neighb->down1) {
- replaceAllNodeInv(neighb->down1, old);
- replaceAllNodeInv(neighb->down2, old);
- }
-}
-
-void replaceAllNodeUp(RNode *neighb, RNode *old)
-{
- /* changes from all neighbours the edgepointers that point to old in old->up */
- if(neighb==0) return;
- if(old->up==0) return;
- neighb= neighb->up;
- if(neighb==0) return;
-
- if(neighb->ed1==old) {
- neighb->ed1= old->up;
- }
- else if(neighb->ed2==old) {
- neighb->ed2= old->up;
- }
- else if(neighb->ed3==old) {
- neighb->ed3= old->up;
- }
- else if(neighb->ed4==old) {
- neighb->ed4= old->up;
- }
-
- if(neighb->up) {
- replaceAllNodeUp(neighb, old);
- }
-}
-
-
-void replaceTestNode(RNode *neighb, RNode **edpp, RNode *newn, int level, float *vert)
-{
- /* IF neighb->ed points to newn->up
- * IF edgelevels equal
- IF testvert is in neighb->ed
- change pointers both ways
- ELSE
- RETURN
- ELSE
- IF neighb edgelevel is deeper
- change neighb pointer
-
- */
- int ok= 0;
-
- if(neighb==0) return;
- if(newn->up==0) return;
-
- if(neighb->ed1==newn->up) {
- if(neighb->lev1==level) {
- if(vert==neighb->v1 || vert==neighb->v2) {
- *edpp= neighb;
- neighb->ed1= newn;
- }
- else return;
- }
- else if(neighb->lev1>level) {
- neighb->ed1= newn;
- }
- ok= 1;
- }
- else if(neighb->ed2==newn->up) {
- if(neighb->lev2==level) {
- if(vert==neighb->v2 || vert==neighb->v3) {
- *edpp= neighb;
- neighb->ed2= newn;
- }
- else return;
- }
- else if(neighb->lev2>level) {
- neighb->ed2= newn;
- }
- ok= 1;
- }
- else if(neighb->ed3==newn->up) {
- if(neighb->lev3==level) {
- if(neighb->type==3) {
- if(vert==neighb->v3 || vert==neighb->v1) {
- *edpp= neighb;
- neighb->ed3= newn;
- }
- else return;
- }
- else {
- if(vert==neighb->v3 || vert==neighb->v4) {
- *edpp= neighb;
- neighb->ed3= newn;
- }
- else return;
- }
- }
- else if(neighb->lev3>level) {
- neighb->ed3= newn;
- }
- ok= 1;
- }
- else if(neighb->ed4==newn->up) {
- if(neighb->lev4==level) {
- if(vert==neighb->v4 || vert==neighb->v1) {
- *edpp= neighb;
- neighb->ed4= newn;
- }
- else return;
- }
- else if(neighb->lev4>level) {
- neighb->ed4= newn;
- }
- ok= 1;
- }
-
- if(ok && neighb->down1) {
- replaceTestNode(neighb->down1, edpp, newn, level, vert);
- replaceTestNode(neighb->down2, edpp, newn, level, vert);
- }
-
-}
-
-int setvertexpointersNode(RNode *neighb, RNode *node, int level, float **v1, float **v2)
-{
- /* compares edgelevels , if equal it sets the vertexpointers */
-
- if(neighb==0) return 0;
-
- if(neighb->ed1==node) {
- if(neighb->lev1==level) {
- *v1= neighb->v1;
- *v2= neighb->v2;
- return 1;
- }
- }
- else if(neighb->ed2==node) {
- if(neighb->lev2==level) {
- *v1= neighb->v2;
- *v2= neighb->v3;
- return 1;
- }
- }
- else if(neighb->ed3==node) {
- if(neighb->lev3==level) {
- if(neighb->type==3) {
- *v1= neighb->v3;
- *v2= neighb->v1;
- }
- else {
- *v1= neighb->v3;
- *v2= neighb->v4;
- }
- return 1;
- }
- }
- else if(neighb->ed4==node) {
- if(neighb->lev4==level) {
- *v1= neighb->v4;
- *v2= neighb->v1;
- return 1;
- }
- }
- return 0;
-}
-
-float edlen(float *v1, float *v2)
-{
- return (v1[0]-v2[0])*(v1[0]-v2[0])+ (v1[1]-v2[1])*(v1[1]-v2[1])+ (v1[2]-v2[2])*(v1[2]-v2[2]);
-}
-
-
-void subdivideTriNode(RNode *node, RNode *edge)
-{
- RNode *n1, *n2, *up;
- float fu, fv, fl, *v1, *v2; /* , AreaT3Dfl(); ... from arithb... */
- int uvl;
-
- if(node->down1 || node->down2) {
- /* printf("trinode: subd already done\n"); */
- return;
- }
-
- /* defines subdivide direction */
-
- if(edge==0) {
- /* areathreshold */
- if(node->area<nodelimit) return;
-
- fu= edlen(node->v1, node->v2);
- fv= edlen(node->v2, node->v3);
- fl= edlen(node->v3, node->v1);
-
- if(fu>fv && fu>fl) uvl= 1;
- else if(fv>fu && fv>fl) uvl= 2;
- else uvl= 3;
- }
- else {
-
- if(edge==node->ed1) uvl= 1;
- else if(edge==node->ed2) uvl= 2;
- else uvl= 3;
- }
-
- /* should neighbour nodes be deeper? Recursive! */
- n1= 0;
- if(uvl==1) {
- if(node->ed1 && node->ed1->down1==0) n1= node->ed1;
- }
- else if(uvl==2) {
- if(node->ed2 && node->ed2->down1==0) n1= node->ed2;
- }
- else {
- if(node->ed3 && node->ed3->down1==0) n1= node->ed3;
- }
- if(n1) {
- up= node->up;
- while(up) { /* also test for ed4 !!! */
- if(n1->ed1==up || n1->ed2==up || n1->ed3==up || n1->ed4==up) {
- subdivideNode(n1, up);
- break;
- }
- up= up->up;
- }
- }
-
- /* the subdividing */
- n1= mallocNode();
- memcpy(n1, node, sizeof(RNode));
- n2= mallocNode();
- memcpy(n2, node, sizeof(RNode));
-
- n1->up= node;
- n2->up= node;
-
- node->down1= n1;
- node->down2= n2;
-
- /* subdivide edge 1 */
- if(uvl==1) {
-
- /* FIRST NODE gets edge 2 */
- n1->ed3= n2;
- n1->lev3= 0;
- replaceAllNode(n1->ed2, n1);
- n1->lev1++;
- replaceTestNode(n1->ed1, &(n1->ed1), n1, n1->lev1, n1->v2);
-
- /* SECOND NODE gets edge 3 */
- n2->ed2= n1;
- n2->lev2= 0;
- replaceAllNode(n2->ed3, n2);
- n2->lev1++;
- replaceTestNode(n2->ed1, &(n2->ed1), n2, n2->lev1, n2->v1);
-
- /* NEW VERTEX from edge 1 */
- if( setvertexpointersNode(n1->ed1, n1, n1->lev1, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v1= v2;
- n2->v2= v2;
- }
- else {
- n1->v1= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v1= n2->v2= mallocVert();
- n1->v1[0]= 0.5*(node->v1[0]+ node->v2[0]);
- n1->v1[1]= 0.5*(node->v1[1]+ node->v2[1]);
- n1->v1[2]= 0.5*(node->v1[2]+ node->v2[2]);
- n1->v1[3]= node->v1[3]; /* color */
- }
- }
- else if(uvl==2) {
-
- /* FIRST NODE gets edge 1 */
- n1->ed3= n2;
- n1->lev3= 0;
- replaceAllNode(n1->ed1, n1);
- n1->lev2++;
- replaceTestNode(n1->ed2, &(n1->ed2), n1, n1->lev2, n1->v2);
-
- /* SECOND NODE gets edge 3 */
- n2->ed1= n1;
- n2->lev1= 0;
- replaceAllNode(n2->ed3, n2);
- n2->lev2++;
- replaceTestNode(n2->ed2, &(n2->ed2), n2, n2->lev2, n2->v3);
-
- /* NEW VERTEX from edge 2 */
- if( setvertexpointersNode(n1->ed2, n1, n1->lev2, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v3= v2;
- n2->v2= v2;
- }
- else {
- n1->v3= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v3= n2->v2= mallocVert();
- n1->v3[0]= 0.5*(node->v2[0]+ node->v3[0]);
- n1->v3[1]= 0.5*(node->v2[1]+ node->v3[1]);
- n1->v3[2]= 0.5*(node->v2[2]+ node->v3[2]);
- n1->v3[3]= node->v1[3]; /* color */
- }
- }
- else if(uvl==3) {
-
- /* FIRST NODE gets edge 1 */
- n1->ed2= n2;
- n1->lev2= 0;
- replaceAllNode(n1->ed1, n1);
- n1->lev3++;
- replaceTestNode(n1->ed3, &(n1->ed3), n1, n1->lev3, n1->v1);
-
- /* SECOND NODE gets edge 2 */
- n2->ed1= n1;
- n2->lev1= 0;
- replaceAllNode(n2->ed2, n2);
- n2->lev3++;
- replaceTestNode(n2->ed3, &(n2->ed3), n2, n2->lev3, n2->v3);
-
- /* NEW VERTEX from edge 3 */
- if( setvertexpointersNode(n1->ed3, n1, n1->lev3, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v1) {
- n1->v3= v2;
- n2->v1= v2;
- }
- else {
- n1->v3= v1;
- n2->v1= v1;
- }
- }
- else {
- n1->v3= n2->v1= mallocVert();
- n1->v3[0]= 0.5*(node->v1[0]+ node->v3[0]);
- n1->v3[1]= 0.5*(node->v1[1]+ node->v3[1]);
- n1->v3[2]= 0.5*(node->v1[2]+ node->v3[2]);
- n1->v3[3]= node->v3[3]; /* color */
- }
- }
- n1->area= AreaT3Dfl(n1->v1, n1->v2, n1->v3);
- n2->area= AreaT3Dfl(n2->v1, n2->v2, n2->v3);
-
-}
-
-
-void subdivideNode(RNode *node, RNode *edge)
-{
- RNode *n1, *n2, *up;
- float fu, fv, *v1, *v2;/*, AreaQ3Dfl(); ... from arithb... */
- int uvl;
-
- if(Ntotnode>RG.maxnode) return;
-
- if(node->type==3) {
- subdivideTriNode(node, edge);
- return;
- }
-
- if(node->down1 || node->down2) {
- /* printf("subdivide Node: already done \n"); */
- return;
- }
-
- /* defines subdivide direction */
-
- if(edge==0) {
- /* areathreshold */
- if(node->area<nodelimit) {
- return;
- }
- fu= fabs(node->v1[0]- node->v2[0])+ fabs(node->v1[1]- node->v2[1]) +fabs(node->v1[2]- node->v2[2]);
- fv= fabs(node->v1[0]- node->v4[0])+ fabs(node->v1[1]- node->v4[1]) +fabs(node->v1[2]- node->v4[2]);
- if(fu>fv) uvl= 1;
- else uvl= 2;
- }
- else {
- if(edge==node->ed1 || edge==node->ed3) uvl= 1;
- else uvl= 2;
- }
-
- /* do neighbour nodes have to be deeper? Recursive! */
- n1= n2= 0;
- if(uvl==1) {
- if(node->ed1 && node->ed1->down1==0) n1= node->ed1;
- if(node->ed3 && node->ed3->down1==0) n2= node->ed3;
- }
- else {
- if(node->ed2 && node->ed2->down1==0) n1= node->ed2;
- if(node->ed4 && node->ed4->down1==0) n2= node->ed4;
- }
- if(n1) {
- up= node->up;
- while(up) {
- if(n1->ed1==up || n1->ed2==up || n1->ed3==up || n1->ed4==up) {
- /* printf("recurs subd\n"); */
- subdivideNode(n1, up);
- break;
- }
- up= up->up;
- }
- }
- if(n2) {
- up= node->up;
- while(up) {
- if(n2->ed1==up || n2->ed2==up || n2->ed3==up || n2->ed4==up) {
- /* printf("recurs subd\n"); */
- subdivideNode(n2, up);
- break;
- }
- up= up->up;
- }
- }
-
- /* the subdividing */
- n1= mallocNode();
- memcpy(n1, node, sizeof(RNode));
- n2= mallocNode();
- memcpy(n2, node, sizeof(RNode));
-
- n1->up= node;
- n2->up= node;
-
- node->down1= n1;
- node->down2= n2;
-
- /* subdivide edge 1 and 3 */
- if(uvl==1) {
-
- /* FIRST NODE gets edge 2 */
- n1->ed4= n2;
- n1->lev4= 0;
- replaceAllNode(n1->ed2, n1);
- n1->lev1++;
- n1->lev3++;
- replaceTestNode(n1->ed1, &(n1->ed1), n1, n1->lev1, n1->v2);
- replaceTestNode(n1->ed3, &(n1->ed3), n1, n1->lev3, n1->v3);
-
- /* SECOND NODE gets edge 4 */
- n2->ed2= n1;
- n2->lev2= 0;
- replaceAllNode(n2->ed4, n2);
- n2->lev1++;
- n2->lev3++;
- replaceTestNode(n2->ed1, &(n2->ed1), n2, n2->lev1, n2->v1);
- replaceTestNode(n2->ed3, &(n2->ed3), n2, n2->lev3, n2->v4);
-
- /* NEW VERTEX from edge 1 */
- if( setvertexpointersNode(n1->ed1, n1, n1->lev1, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v1= v2;
- n2->v2= v2;
- }
- else {
- n1->v1= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v1= n2->v2= mallocVert();
- n1->v1[0]= 0.5*(node->v1[0]+ node->v2[0]);
- n1->v1[1]= 0.5*(node->v1[1]+ node->v2[1]);
- n1->v1[2]= 0.5*(node->v1[2]+ node->v2[2]);
- n1->v1[3]= node->v1[3]; /* color */
- }
-
- /* NEW VERTEX from edge 3 */
- if( setvertexpointersNode(n1->ed3, n1, n1->lev3, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v3) {
- n1->v4= v2;
- n2->v3= v2;
- }
- else {
- n1->v4= v1;
- n2->v3= v1;
- }
- }
- else {
- n1->v4= n2->v3= mallocVert();
- n1->v4[0]= 0.5*(node->v3[0]+ node->v4[0]);
- n1->v4[1]= 0.5*(node->v3[1]+ node->v4[1]);
- n1->v4[2]= 0.5*(node->v3[2]+ node->v4[2]);
- n1->v4[3]= node->v4[3]; /* color */
- }
- }
- /* subdivide edge 2 and 4 */
- else if(uvl==2) {
-
- /* FIRST NODE gets edge 1 */
- n1->ed3= n2;
- n1->lev3= 0;
- replaceAllNode(n1->ed1, n1);
- n1->lev2++;
- n1->lev4++;
- replaceTestNode(n1->ed2, &(n1->ed2), n1, n1->lev2, n1->v2);
- replaceTestNode(n1->ed4, &(n1->ed4), n1, n1->lev4, n1->v1);
-
- /* SECOND NODE gets edge 3 */
- n2->ed1= n1;
- n2->lev1= 0;
- replaceAllNode(n2->ed3, n2);
- n2->lev2++;
- n2->lev4++;
- replaceTestNode(n2->ed2, &(n2->ed2), n2, n2->lev2, n2->v3);
- replaceTestNode(n2->ed4, &(n2->ed4), n2, n2->lev4, n2->v4);
-
- /* NEW VERTEX from edge 2 */
- if( setvertexpointersNode(n1->ed2, n1, n1->lev2, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v3= v2;
- n2->v2= v2;
- }
- else {
- n1->v3= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v3= n2->v2= mallocVert();
- n1->v3[0]= 0.5*(node->v2[0]+ node->v3[0]);
- n1->v3[1]= 0.5*(node->v2[1]+ node->v3[1]);
- n1->v3[2]= 0.5*(node->v2[2]+ node->v3[2]);
- n1->v3[3]= node->v3[3]; /* color */
- }
-
- /* NEW VERTEX from edge 4 */
- if( setvertexpointersNode(n1->ed4, n1, n1->lev4, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v1) {
- n1->v4= v2;
- n2->v1= v2;
- }
- else {
- n1->v4= v1;
- n2->v1= v1;
- }
- }
- else {
- n1->v4= n2->v1= mallocVert();
- n1->v4[0]= 0.5*(node->v1[0]+ node->v4[0]);
- n1->v4[1]= 0.5*(node->v1[1]+ node->v4[1]);
- n1->v4[2]= 0.5*(node->v1[2]+ node->v4[2]);
- n1->v4[3]= node->v4[3]; /* color */
- }
- }
-
- n1->area= AreaQ3Dfl(n1->v1, n1->v2, n1->v3, n1->v4);
- n2->area= AreaQ3Dfl(n2->v1, n2->v2, n2->v3, n2->v4);
-
-}
-
-int comparelevel(RNode *node, RNode *nb, int level)
-{
- /* recursive descent: test with deepest node */
- /* return 1 means equal or higher */
-
- if(nb==0) return 1;
-
- if(nb->down1) {
- return 0;
-
- /* THERE IS AN ERROR HERE, BUT WHAT? (without this function the system
- works too, but is slower) (ton) */
-
- /*
- n1= nb->down1;
- if(n1->ed1==node) return comparelevel(node, n1, level);
- if(n1->ed2==node) return comparelevel(node, n1, level);
- if(n1->ed3==node) return comparelevel(node, n1, level);
- if(n1->ed4==node) return comparelevel(node, n1, level);
- n1= nb->down2;
- if(n1->ed1==node) return comparelevel(node, n1, level);
- if(n1->ed2==node) return comparelevel(node, n1, level);
- if(n1->ed3==node) return comparelevel(node, n1, level);
- if(n1->ed4==node) return comparelevel(node, n1, level);
- printf(" dit kan niet ");
- return 0;
- */
-
- }
-
- if(nb->down1==0) {
- /* if(nb->ed1==node) return (nb->lev1<=level); */
- /* if(nb->ed2==node) return (nb->lev2<=level); */
- /* if(nb->ed3==node) return (nb->lev3<=level); */
- /* if(nb->ed4==node) return (nb->lev4<=level); */
-
- return 1; /* is higher node */
- }
- return 1;
-}
-
-static void deleteTriNodes(RNode *node) /* both children of node */
-{
- RNode *n1, *n2;
-
- /* if neighbour nodes are deeper: no delete */
- /* just test 2 nodes, from the others the level doesn't change */
-
- n1= node->down1;
- n2= node->down2;
-
- if(n1==0 || n2==0) return;
-
- if(n1->down1 || n2->down1) return;
-
- /* at the edges no subdivided node is allowed */
-
- if(n1->ed1 && n1->ed1->down1) return;
- if(n1->ed2 && n1->ed2->down1) return;
- if(n1->ed3 && n1->ed3->down1) return;
-
- if(n2->ed1 && n2->ed1->down1) return;
- if(n2->ed2 && n2->ed2->down1) return;
- if(n2->ed3 && n2->ed3->down1) return;
-
- replaceAllNodeInv(n1->ed1, n1);
- replaceAllNodeInv(n1->ed2, n1);
- replaceAllNodeInv(n1->ed3, n1);
-
- replaceAllNodeUp(n1->ed1, n1);
- replaceAllNodeUp(n1->ed2, n1);
- replaceAllNodeUp(n1->ed3, n1);
-
- replaceAllNodeInv(n2->ed1, n2);
- replaceAllNodeInv(n2->ed2, n2);
- replaceAllNodeInv(n2->ed3, n2);
-
- replaceAllNodeUp(n2->ed1, n2);
- replaceAllNodeUp(n2->ed2, n2);
- replaceAllNodeUp(n2->ed3, n2);
-
- n1->down1= (RNode *)12; /* for debug */
- n2->down1= (RNode *)12;
-
- freeNode(n1);
- freeNode(n2);
- node->down1= node->down2= 0;
-
-}
-
- /* both children of node */
-void deleteNodes(RNode *node)
-{
- RNode *n1, *n2;
-
- /* if neighbour nodes are deeper: no delete */
- /* just test 2 nodes, from the others the level doesn't change */
-
- if(node->type==3) {
- deleteTriNodes(node);
- return;
- }
-
- n1= node->down1;
- n2= node->down2;
-
- if(n1==0 || n2==0) return;
-
- if(n1->down1 || n2->down1) return;
-
- if(n1->ed3==n2) {
-
- /* at the edges no subdivided node is allowed */
-
- if(n1->ed1 && n1->ed1->down1) return;
- if(n1->ed2 && n1->ed2->down1) return;
- if(n1->ed4 && n1->ed4->down1) return;
-
- if(n2->ed2 && n2->ed2->down1) return;
- if(n2->ed3 && n2->ed3->down1) return;
- if(n2->ed4 && n2->ed4->down1) return;
-
- replaceAllNodeInv(n1->ed1, n1);
- replaceAllNodeInv(n1->ed2, n1);
- replaceAllNodeInv(n1->ed4, n1);
-
- replaceAllNodeUp(n1->ed1, n1);
- replaceAllNodeUp(n1->ed2, n1);
- replaceAllNodeUp(n1->ed4, n1);
-
- replaceAllNodeInv(n2->ed2, n2);
- replaceAllNodeInv(n2->ed3, n2);
- replaceAllNodeInv(n2->ed4, n2);
-
- replaceAllNodeUp(n2->ed2, n2);
- replaceAllNodeUp(n2->ed3, n2);
- replaceAllNodeUp(n2->ed4, n2);
-
- n1->down1= (RNode *)12; /* for debug */
- n2->down1= (RNode *)12;
-
- freeNode(n1);
- freeNode(n2);
- node->down1= node->down2= 0;
-
- return;
- }
- else if(n1->ed4==n2) {
-
- if(n1->ed1 && n1->ed1->down1) return;
- if(n1->ed2 && n1->ed2->down1) return;
- if(n1->ed3 && n1->ed3->down1) return;
-
- if(n2->ed1 && n2->ed1->down1) return;
- if(n2->ed3 && n2->ed3->down1) return;
- if(n2->ed4 && n2->ed4->down1) return;
-
- replaceAllNodeInv(n1->ed1, n1);
- replaceAllNodeInv(n1->ed2, n1);
- replaceAllNodeInv(n1->ed3, n1);
-
- replaceAllNodeUp(n1->ed1, n1);
- replaceAllNodeUp(n1->ed2, n1);
- replaceAllNodeUp(n1->ed3, n1);
-
- replaceAllNodeInv(n2->ed1, n2);
- replaceAllNodeInv(n2->ed3, n2);
- replaceAllNodeInv(n2->ed4, n2);
-
- replaceAllNodeUp(n2->ed1, n2);
- replaceAllNodeUp(n2->ed3, n2);
- replaceAllNodeUp(n2->ed4, n2);
-
- n1->down1= (RNode *)12; /* for debug */
- n2->down1= (RNode *)12;
-
- freeNode(n1);
- freeNode(n2);
- node->down1= node->down2= 0;
-
- return;
- }
-
-}
-
-
diff --git a/source/blender/radiosity/intern/source/radpostprocess.c b/source/blender/radiosity/intern/source/radpostprocess.c
deleted file mode 100644
index 6912c737a51..00000000000
--- a/source/blender/radiosity/intern/source/radpostprocess.c
+++ /dev/null
@@ -1,824 +0,0 @@
-/* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- radpostprocess.c nov/dec 1992
- may 1999
-
- - faces
- - filtering and node-limit
- - apply to meshes
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_ghash.h"
-
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_radio_types.h"
-#include "DNA_scene_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_mesh.h"
-#include "BKE_object.h"
-#include "BKE_utildefines.h"
-
-#include "radio.h"
-
-/* locals? not. done in radio.h... */
-/* void rad_addmesh(void); */
-/* void rad_replacemesh(void); */
-
-void addaccu(register char *z, register char *t)
-{
- register int div, mul;
-
- mul= *t;
- div= mul+1;
- (*t)++;
-
- t[1]= (mul*t[1]+z[1])/div;
- t[2]= (mul*t[2]+z[2])/div;
- t[3]= (mul*t[3]+z[3])/div;
-
-}
-
-void addaccuweight(register char *z, register char *t, int w)
-{
- register int div, mul;
-
- if(w==0) w= 1;
-
- mul= *t;
- div= mul+w;
- if(div>255) return;
- (*t)= div;
-
- t[1]= (mul*t[1]+w*z[1])/div;
- t[2]= (mul*t[2]+w*z[2])/div;
- t[3]= (mul*t[3]+w*z[3])/div;
-
-}
-
-void triaweight(Face *face, int *w1, int *w2, int *w3)
-{
- float n1[3], n2[3], n3[3], temp;
-
- n1[0]= face->v2[0]-face->v1[0];
- n1[1]= face->v2[1]-face->v1[1];
- n1[2]= face->v2[2]-face->v1[2];
- n2[0]= face->v3[0]-face->v2[0];
- n2[1]= face->v3[1]-face->v2[1];
- n2[2]= face->v3[2]-face->v2[2];
- n3[0]= face->v1[0]-face->v3[0];
- n3[1]= face->v1[1]-face->v3[1];
- n3[2]= face->v1[2]-face->v3[2];
- Normalize(n1);
- Normalize(n2);
- Normalize(n3);
- temp= 32.0/(PI);
- *w1= 0.5+temp*acos(-n1[0]*n3[0]-n1[1]*n3[1]-n1[2]*n3[2]);
- *w2= 0.5+temp*acos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2]);
- *w3= 0.5+temp*acos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2]);
-
-}
-
-
-
-void init_face_tab()
-{
- int a= 0;
-
- if(RG.facebase==0) {
- RG.facebase= MEM_callocN(sizeof(void *)*RAD_MAXFACETAB, "init_face_tab");
- }
- for(a=0; a<RAD_MAXFACETAB; a++) {
- if(RG.facebase[a]==0) break;
- MEM_freeN(RG.facebase[a]);
- RG.facebase[a]= 0;
- }
- RG.totface= 0;
-}
-
-Face *addface()
-{
- Face *face;
- int a;
-
- if(RG.totface<0 || RG.totface>RAD_MAXFACETAB*1024 ) {
- printf("error in addface: %d\n", RG.totface);
- return 0;
- }
- a= RG.totface>>10;
- face= RG.facebase[a];
- if(face==0) {
- face= MEM_callocN(1024*sizeof(Face),"addface");
- RG.facebase[a]= face;
- }
- face+= (RG.totface & 1023);
-
- RG.totface++;
-
- return face;
-
-}
-
-Face * makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn)
-{
- Face *face;
-
- face= addface();
- face->v1= v1;
- face->v2= v2;
- face->v3= v3;
- face->v4= v4;
- face->col= rn->col;
- face->matindex= rn->par->matindex;
- face->orig= rn->orig;
-
- return face;
-}
-
-void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int flag)
-{
- Face *face;
-
- switch(flag) {
- case 1:
- face = makeface(rn->v1, v1, rn->v4, NULL, rn);
- face = makeface(v1, rn->v3, rn->v4, NULL, rn);
- face = makeface(v1, rn->v2, rn->v3, NULL, rn);
- break;
- case 2:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn);
- face = makeface(v2, rn->v4, rn->v1, NULL, rn);
- face = makeface(v2, rn->v3, rn->v4, NULL, rn);
- break;
- case 4:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn);
- face = makeface(v3, rn->v1, rn->v2, NULL, rn);
- face = makeface(v3, rn->v4, rn->v1, NULL, rn);
- break;
- case 8:
- face = makeface(rn->v4, v4, rn->v3, NULL, rn);
- face = makeface(v4, rn->v2, rn->v3, NULL, rn);
- face = makeface(v4, rn->v1, rn->v2, NULL, rn);
- break;
- case 3:
- face = makeface(rn->v1, v1, rn->v4, NULL, rn);
- face = makeface(v1, v2, rn->v4, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- face = makeface(v2, rn->v3, rn->v4, NULL, rn);
- break;
- case 6:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn);
- face = makeface(v2, v3, rn->v1, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- face = makeface(v3, rn->v4, rn->v1, NULL, rn);
- break;
- case 12:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn);
- face = makeface(v3, v4, rn->v2, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- face = makeface(v4, rn->v1, rn->v2, NULL, rn);
- break;
- case 9:
- face = makeface(rn->v4, v4, rn->v3, NULL, rn);
- face = makeface(v4, v1, rn->v3, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- face = makeface(v1, rn->v2, rn->v3, NULL, rn);
- break;
- case 5:
- face = makeface(rn->v1, v1, v3, rn->v4, rn);
- face = makeface(v1, rn->v2, rn->v3, v3, rn);
- break;
- case 10:
- face = makeface(rn->v1, rn->v2, v2, v4, rn);
- face = makeface(v4, v2, rn->v3, rn->v4, rn);
- break;
- case 7:
- face = makeface(rn->v1, v1, v3, rn->v4, rn);
- face = makeface(v1, v2, v3, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- break;
- case 14:
- face = makeface(rn->v2, v2, v4, rn->v1, rn);
- face = makeface(v2, v3, v4, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- break;
- case 13:
- face = makeface(rn->v3, v3, v1, rn->v2, rn);
- face = makeface(v3, v4, v1, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- break;
- case 11:
- face = makeface(rn->v4, v4, v2, rn->v3, rn);
- face = makeface(v4, v1, v2, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- break;
- case 15:
- face = makeface(v1, v2, v3, v4, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- break;
- }
-}
-
-void anchorTriface(RNode *rn, float *v1, float *v2, float *v3, int flag)
-{
- Face *face;
-
- switch(flag) {
- case 1:
- face = makeface(rn->v1, v1, rn->v3, NULL, rn);
- face = makeface(v1, rn->v2, rn->v3, NULL, rn);
- break;
- case 2:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn);
- face = makeface(v2, rn->v3, rn->v1, NULL, rn);
- break;
- case 4:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn);
- face = makeface(v3, rn->v1, rn->v2, NULL, rn);
- break;
- case 3:
- face = makeface(rn->v1, v2, rn->v3, NULL, rn);
- face = makeface(rn->v1, v1, v2, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- break;
- case 6:
- face = makeface(rn->v2, v3, rn->v1, NULL, rn);
- face = makeface(rn->v2, v2, v3, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- break;
- case 5:
- face = makeface(rn->v3, v1, rn->v2, NULL, rn);
- face = makeface(rn->v3, v3, v1, NULL, rn);
- face = makeface(v3, rn->v1, v1, NULL, rn);
- break;
-
- case 7:
- face = makeface(v1, v2, v3, NULL, rn);
- face = makeface(rn->v1, v1, v3, NULL, rn);
- face = makeface(rn->v2, v2, v1, NULL, rn);
- face = makeface(rn->v3, v3, v2, NULL, rn);
- break;
- }
-}
-
-
-float *findmiddlevertex(RNode *node, RNode *nb, float *v1, float *v2)
-{
- int test= 0;
-
- if(nb==0) return 0;
-
- if(nb->ed1==node) {
- if(nb->v1==v1 || nb->v1==v2) test++;
- if(nb->v2==v1 || nb->v2==v2) test+=2;
- if(test==1) return nb->v2;
- else if(test==2) return nb->v1;
- }
- else if(nb->ed2==node) {
- if(nb->v2==v1 || nb->v2==v2) test++;
- if(nb->v3==v1 || nb->v3==v2) test+=2;
- if(test==1) return nb->v3;
- else if(test==2) return nb->v2;
- }
- else if(nb->ed3==node) {
- if(nb->type==4) {
- if(nb->v3==v1 || nb->v3==v2) test++;
- if(nb->v4==v1 || nb->v4==v2) test+=2;
- if(test==1) return nb->v4;
- else if(test==2) return nb->v3;
- }
- else {
- if(nb->v3==v1 || nb->v3==v2) test++;
- if(nb->v1==v1 || nb->v1==v2) test+=2;
- if(test==1) return nb->v1;
- else if(test==2) return nb->v3;
- }
- }
- else if(nb->ed4==node) {
- if(nb->v4==v1 || nb->v4==v2) test++;
- if(nb->v1==v1 || nb->v1==v2) test+=2;
- if(test==1) return nb->v1;
- else if(test==2) return nb->v4;
- }
- return 0;
-}
-
-void make_face_tab() /* takes care of anchoring */
-{
- RNode *rn, **el;
- Face *face = NULL;
- float *v1, *v2, *v3, *v4;
- int a, flag, w1, w2, w3;
- char *charcol;
-
- if(RG.totelem==0) return;
-
- init_face_tab();
-
- RG.igamma= 1.0/RG.gamma;
- RG.radfactor= RG.radfac*pow(64*64, RG.igamma);
-
- /* convert face colors */
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- charcol= (char *)&( rn->col );
-
- charcol[3]= calculatecolor(rn->totrad[0]);
- charcol[2]= calculatecolor(rn->totrad[1]);
- charcol[1]= calculatecolor(rn->totrad[2]);
- }
-
- /* check nodes and make faces */
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
-
- rn= *el;
-
- rn->v1[3]= 0.0;
- rn->v2[3]= 0.0;
- rn->v3[3]= 0.0;
- if(rn->v4) rn->v4[3]= 0.0;
-
- /* test edges for subdivide */
- flag= 0;
- v1= v2= v3= v4= 0;
- if(rn->ed1) {
- v1= findmiddlevertex(rn, rn->ed1->down1, rn->v1, rn->v2);
- if(v1) flag |= 1;
- }
- if(rn->ed2) {
- v2= findmiddlevertex(rn, rn->ed2->down1, rn->v2, rn->v3);
- if(v2) flag |= 2;
- }
- if(rn->ed3) {
- if(rn->type==4)
- v3= findmiddlevertex(rn, rn->ed3->down1, rn->v3, rn->v4);
- else
- v3= findmiddlevertex(rn, rn->ed3->down1, rn->v3, rn->v1);
- if(v3) flag |= 4;
- }
- if(rn->ed4) {
- v4= findmiddlevertex(rn, rn->ed4->down1, rn->v4, rn->v1);
- if(v4) flag |= 8;
- }
-
- /* using flag and vertexpointers now Faces can be made */
-
- if(flag==0) {
- makeface(rn->v1, rn->v2, rn->v3, rn->v4, rn);
- }
- else if(rn->type==4) anchorQuadface(rn, v1, v2, v3, v4, flag);
- else anchorTriface(rn, v1, v2, v3, flag);
- }
-
- /* add */
- for(a=0; a<RG.totface; a++) {
-
- RAD_NEXTFACE(a);
-
- if(face->v4) {
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v4+3), 16 );
- }
- else {
- triaweight(face, &w1, &w2, &w3);
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), w1 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), w2 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), w3 );
- }
- }
-
-}
-
-void filterFaces()
-{
- /* put vertex colors in faces, and put them back */
-
- Face *face = NULL;
- int a, w1, w2, w3;
-
- if(RG.totface==0) return;
-
- /* clear */
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
- face->col= 0;
- }
-
- /* add: vertices with faces */
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
-
- if(face->v4) {
- addaccuweight( (char *)(face->v1+3), (char *)&(face->col), 16 );
- addaccuweight( (char *)(face->v2+3), (char *)&(face->col), 16 );
- addaccuweight( (char *)(face->v3+3), (char *)&(face->col), 16 );
- addaccuweight( (char *)(face->v4+3), (char *)&(face->col), 16 );
- }
- else {
- triaweight(face, &w1, &w2, &w3);
- addaccuweight( (char *)(face->v1+3), (char *)&(face->col), w1 );
- addaccuweight( (char *)(face->v2+3), (char *)&(face->col), w2 );
- addaccuweight( (char *)(face->v3+3), (char *)&(face->col), w3 );
- }
- }
-
- /* clear */
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
- face->v1[3]= 0.0;
- face->v2[3]= 0.0;
- face->v3[3]= 0.0;
- if(face->v4) face->v4[3]= 0.0;
- }
-
-
- /* add: faces with vertices */
- for(a=0; a<RG.totface; a++) {
-
- RAD_NEXTFACE(a);
-
- if(face->v4) {
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v4+3), 16 );
- }
- else {
- triaweight(face, &w1, &w2, &w3);
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), w1 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), w2 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), w3 );
- }
- }
-}
-
-void calcfiltrad(RNode *rn, float *cd)
-{
- float area;
-
- cd[0]= 2.0*rn->totrad[0];
- cd[1]= 2.0*rn->totrad[1];
- cd[2]= 2.0*rn->totrad[2];
- area= 2.0;
-
- if(rn->ed1) {
- cd[0]+= rn->ed1->totrad[0];
- cd[1]+= rn->ed1->totrad[1];
- cd[2]+= rn->ed1->totrad[2];
- area+= 1.0;
- }
- if(rn->ed2) {
- cd[0]+= rn->ed2->totrad[0];
- cd[1]+= rn->ed2->totrad[1];
- cd[2]+= rn->ed2->totrad[2];
- area+= 1.0;
- }
- if(rn->ed3) {
- cd[0]+= rn->ed3->totrad[0];
- cd[1]+= rn->ed3->totrad[1];
- cd[2]+= rn->ed3->totrad[2];
- area+= 1.0;
- }
- if(rn->ed4) {
- cd[0]+= rn->ed4->totrad[0];
- cd[1]+= rn->ed4->totrad[1];
- cd[2]+= rn->ed4->totrad[2];
- area+= 1.0;
- }
- cd[0]/= area;
- cd[1]/= area;
- cd[2]/= area;
-
-}
-
-void filterNodes()
-{
- /* colors from nodes in tempblock and back */
-
- RNode *rn, **el;
- float *coldata, *cd;
- int a;
-
- if(RG.totelem==0) return;
- /* the up-nodes need a color */
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- rn= *el;
- if(rn->up) {
- rn->up->totrad[0]= 0.0;
- rn->up->totrad[1]= 0.0;
- rn->up->totrad[2]= 0.0;
- if(rn->up->up) {
- rn->up->up->totrad[0]= 0.0;
- rn->up->up->totrad[1]= 0.0;
- rn->up->up->totrad[2]= 0.0;
- }
- }
- }
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- rn= *el;
- if(rn->up) {
- rn->up->totrad[0]+= 0.5*rn->totrad[0];
- rn->up->totrad[1]+= 0.5*rn->totrad[1];
- rn->up->totrad[2]+= 0.5*rn->totrad[2];
- if(rn->up->up) {
- rn->up->up->totrad[0]+= 0.25*rn->totrad[0];
- rn->up->up->totrad[1]+= 0.25*rn->totrad[1];
- rn->up->up->totrad[2]+= 0.25*rn->totrad[2];
- }
- }
- }
-
- /* add using area */
- cd= coldata= MEM_mallocN(3*4*RG.totelem, "filterNodes");
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- calcfiltrad(*el, cd);
- cd+= 3;
- }
-
- cd= coldata;
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- rn= *el;
- VECCOPY(rn->totrad, cd);
- cd+= 3;
- }
- MEM_freeN(coldata);
-}
-
-void removeEqualNodes(short limit)
-{
- /* nodes with equal colors: remove */
- RNode **el, *rn, *rn1;
- float thresh, f1, f2;
- int a, foundone=1, ok;
- int c1, c2;
-
- if(limit==0) return;
-
- thresh= 1.0/(256.0*RG.radfactor);
- thresh= 3.0*pow(thresh, RG.gamma);
-
-// XXX waitcursor(1);
-
- while(foundone) {
- foundone= 0;
-
- el= RG.elem;
- for(a=RG.totelem; a>1; a--, el++) {
- rn= *el;
- rn1= *(el+1);
-
- if(rn!=rn->par->first && rn1!=rn1->par->first) {
- if(rn->up && rn->up==rn1->up) {
- f1= rn->totrad[0]+ rn->totrad[1]+ rn->totrad[2];
- f2= rn1->totrad[0]+ rn1->totrad[1]+ rn1->totrad[2];
-
- ok= 0;
- if(f1<thresh && f2<thresh) ok= 1;
- else {
- c1= calculatecolor(rn->totrad[0]);
- c2= calculatecolor(rn1->totrad[0]);
-
- if( abs(c1-c2)<=limit ) {
- c1= calculatecolor(rn->totrad[1]);
- c2= calculatecolor(rn1->totrad[1]);
-
- if( abs(c1-c2)<=limit ) {
- c1= calculatecolor(rn->totrad[2]);
- c2= calculatecolor(rn1->totrad[2]);
-
- if( abs(c1-c2)<=limit ) {
- ok= 1;
- }
- }
- }
- }
-
- if(ok) {
- rn->up->totrad[0]= 0.5f*(rn->totrad[0]+rn1->totrad[0]);
- rn->up->totrad[1]= 0.5f*(rn->totrad[1]+rn1->totrad[1]);
- rn->up->totrad[2]= 0.5f*(rn->totrad[2]+rn1->totrad[2]);
- rn1= rn->up;
- deleteNodes(rn1);
- if(rn1->down1) ;
- else {
- foundone++;
- a--; el++;
- }
- }
- }
- }
- }
- if(foundone) {
- makeGlobalElemArray();
- }
- }
-// XXX waitcursor(0);
-}
-
-unsigned int rad_find_or_add_mvert(Mesh *me, MFace *mf, RNode *orignode, float *w, float *radco, GHash *hash)
-{
- MVert *mvert = BLI_ghash_lookup(hash, radco);
-
- if(!mvert) {
- mvert = &me->mvert[me->totvert];
- VECCOPY(mvert->co, radco);
- me->totvert++;
-
- BLI_ghash_insert(hash, radco, mvert);
- }
-
- InterpWeightsQ3Dfl(orignode->v1, orignode->v2, orignode->v3,
- orignode->v4, mvert->co, w);
-
- return (unsigned int)(mvert - me->mvert);
-}
-
-void rad_addmesh(Scene *scene)
-{
- Face *face = NULL;
- Object *ob;
- Mesh *me;
- MVert *mvert;
- MFace *mf;
- RNode *node;
- Material *ma=0;
- GHash *verthash;
- unsigned int *mcol;
- float cent[3], min[3], max[3], w[4][4];
- int a;
-
- if(RG.totface==0)
- return;
-
-// if(RG.totmat==MAXMAT)
-// XXX notice("warning: cannot assign more than 16 materials to 1 mesh");
-
- /* create the mesh */
- ob= add_object(scene, OB_MESH);
-
- me= ob->data;
- me->totvert= totalRadVert();
- me->totface= RG.totface;
- me->flag= 0;
-
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
- CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
- CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
-
- CustomData_merge(RG.mfdata, &me->fdata, CD_MASK_MESH, CD_CALLOC, me->totface);
- mesh_update_customdata_pointers(me);
-
- /* create materials and set vertex color flag */
- for(a=0; a<RG.totmat; a++) {
- assign_material(ob, RG.matar[a], a+1);
- ma= RG.matar[a];
- if(ma) ma->mode |= MA_VERTEXCOL;
- }
-
- /* create vertices and faces in one go, adding vertices to the end of the
- mvert array if they were not added already */
- me->totvert= 0;
- verthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
-
- mcol= (unsigned int*)me->mcol;
- mf= me->mface;
-
- for(a=0; a<me->totface; a++, mf++, mcol+=4) {
- RAD_NEXTFACE(a);
-
- /* the original node that this node is a subnode of */
- node= RG.mfdatanodes[face->orig];
-
- /* set mverts from the radio data, and compute interpolation weights */
- mf->v1= rad_find_or_add_mvert(me, mf, node, w[0], face->v1, verthash);
- mf->v2= rad_find_or_add_mvert(me, mf, node, w[1], face->v2, verthash);
- mf->v3= rad_find_or_add_mvert(me, mf, node, w[2], face->v3, verthash);
- if(face->v4)
- mf->v4= rad_find_or_add_mvert(me, mf, node, w[3], face->v4, verthash);
-
- /* copy face and interpolate data */
- mf->mat_nr= face->matindex;
-
- CustomData_copy_data(RG.mfdata, &me->fdata, face->orig, a, 1);
- CustomData_interp(RG.mfdata, &me->fdata, &face->orig, NULL, (float*)w, 1, a);
-
- /* load face vertex colors, with alpha added */
- mcol[0]= *((unsigned int*)face->v1+3) | 0x1000000;
- mcol[1]= *((unsigned int*)face->v2+3) | 0x1000000;
- mcol[2]= *((unsigned int*)face->v3+3) | 0x1000000;
- if(face->v4)
- mcol[3]= *((unsigned int*)face->v4+3) | 0x1000000;
-
- /* reorder face indices if needed to make face->v4 == 0 */
- test_index_face(mf, &me->fdata, a, face->v4? 4: 3);
- }
-
- BLI_ghash_free(verthash, NULL, NULL);
-
- /* boundbox and center new */
- INIT_MINMAX(min, max);
-
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- DO_MINMAX(mvert->co, min, max);
- }
-
- cent[0]= (min[0]+max[0])/2.0f;
- cent[1]= (min[1]+max[1])/2.0f;
- cent[2]= (min[2]+max[2])/2.0f;
-
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- VecSubf(mvert->co, mvert->co, cent);
- }
-
- VECCOPY(ob->loc, cent);
-
- /* create edges */
- make_edges(me, 0);
-}
-
-void rad_replacemesh(Scene *scene)
-{
- RPatch *rp;
-
-// XXX deselectall();
-
- rp= RG.patchbase.first;
- while(rp) {
- if( exist_object(rp->from)) {
- if (rp->from->type == OB_MESH) {
- rp->from->flag |= SELECT;
- }
- }
- rp= rp->next;
- }
-
- copy_objectflags(scene);
-// XXX delete_obj(1);
-
- rad_addmesh(scene);
-}
-
diff --git a/source/blender/radiosity/intern/source/radpreprocess.c b/source/blender/radiosity/intern/source/radpreprocess.c
deleted file mode 100644
index 2b3ce1a856b..00000000000
--- a/source/blender/radiosity/intern/source/radpreprocess.c
+++ /dev/null
@@ -1,828 +0,0 @@
- /* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- preproces.c nov/dec 1992
- may 1999
-
- - collect from meshes
- - countglobaldata()
- - makeGlobalElemArray()
-
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_view3d_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_mesh.h"
-#include "BKE_object.h" /* during_script() */
-#include "BKE_utildefines.h"
-
-#include "radio.h"
-
-#include "BLO_sys_types.h" // for intptr_t support
-
-void setparelem(RNode *rn, RPatch *par);
-
-void splitconnected()
-{
- /* Since input meshes can have faces with sharing vertices, the geometry is being tested here.
- * Using normals and colors, faces are split separately. we do this by storing for each
- * vertex a normal and a color
- */
- RPatch *rp;
- RNode *rn;
- VeNoCo *vnc, *next, *vnc1;
- int a;
-
- /* test if we need a split */
-
- rp= RG.patchbase.first;
- while(rp) {
- rn= rp->first;
- if((rp->f1 & RAD_NO_SPLIT)==0) {
- for(a=0; a<rp->type; a++) {
-
- if(a==0) vnc= (VeNoCo *)rn->v1;
- else if(a==1) vnc= (VeNoCo *)rn->v2;
- else if(a==2) vnc= (VeNoCo *)rn->v3;
- else vnc= (VeNoCo *)rn->v4;
-
- if(vnc->flag==0) {
- vnc->n= (float *)rp->norm;
- vnc->col= (float *)rp->ref;
- vnc->flag= 1;
- }
- else { /* is face from this vertex allowed for gouraud? */
- vnc1= vnc;
- while(vnc1) {
- if(VecCompare(vnc1->n, rp->norm, 0.01f)) {
- if(VecCompare(vnc1->col, rp->ref, 0.01f)) {
- break;
- }
- }
- vnc= vnc1;
- vnc1= vnc1->next;
- }
- if(vnc1==0) {
- vnc1= MEM_mallocN(sizeof(VeNoCo), "splitconn");
- vnc1->next= 0;
- vnc1->v= mallocVert();
- vnc->next= vnc1;
- VECCOPY(vnc1->v, vnc->v);
- vnc1->n= (float *)rp->norm;
- vnc1->col= (float *)rp->ref;
- }
- if(a==0) rn->v1= (float *)vnc1;
- else if(a==1) rn->v2= (float *)vnc1;
- else if(a==2) rn->v3= (float *)vnc1;
- else rn->v4= (float *)vnc1;
- }
- }
- }
- rp= rp->next;
- }
- /* adapt vertexpointers from nodes */
-
- rp= RG.patchbase.first;
- while(rp) {
- rn= rp->first;
- rn->v1= ((VeNoCo *)(rn->v1))->v;
- rn->v2= ((VeNoCo *)(rn->v2))->v;
- rn->v3= ((VeNoCo *)(rn->v3))->v;
- if(rp->type==4) rn->v4= ((VeNoCo *)(rn->v4))->v;
-
- rp= rp->next;
- }
-
-
- /* free all */
- vnc= RG.verts;
- for(a=0; a<RG.totvert; a++) {
- vnc1= vnc->next;
- while(vnc1) {
- next= vnc1->next;
- MEM_freeN(vnc1);
- vnc1= next;
- }
- vnc++;
- }
- MEM_freeN(RG.verts);
- RG.verts= 0;
-}
-
-int vergedge(const void *v1,const void *v2)
-{
- int *e1, *e2;
-
- e1= (int *)v1;
- e2= (int *)v2;
-
- if( e1[0] > e2[0] ) return 1;
- else if( e1[0] < e2[0] ) return -1;
- else if( e1[1] > e2[1] ) return 1;
- else if( e1[1] < e2[1] ) return -1;
-
- return 0;
-}
-
-
-void addedge(float *v1, float *v2, EdSort *es)
-{
- if( ((intptr_t)v1)<((intptr_t)v2) ) {
- es->v1= v1;
- es->v2= v2;
- }
- else {
- es->v2= v1;
- es->v1= v2;
- }
-}
-
-static void setedge(RNode *node, RNode *nb, int nr, int nrb)
-{
- switch(nr) {
- case 1:
- node->ed1= nb;
- break;
- case 2:
- node->ed2= nb;
- break;
- case 3:
- node->ed3= nb;
- break;
- case 4:
- node->ed4= nb;
- break;
- }
- switch(nrb) {
- case 1:
- nb->ed1= node;
- break;
- case 2:
- nb->ed2= node;
- break;
- case 3:
- nb->ed3= node;
- break;
- case 4:
- nb->ed4= node;
- break;
- }
-}
-
-void setedgepointers()
-{
- /* make edge-array and sort it */
- /* pairs of edges are put together: fill in pointers in nodes */
- EdSort *es, *esblock;
- RPatch *rp;
- RNode *rn;
- int tot= 0;
-
- rp= RG.patchbase.first;
- while(rp) {
- tot+= rp->type;
- rp= rp->next;
- }
-
- if(tot==0) return;
-
- es=esblock= MEM_mallocN(tot*sizeof(EdSort), "setedgepointers");
- rp= RG.patchbase.first;
- while(rp) {
- rn= rp->first;
- addedge(rn->v1, rn->v2, es);
- es->nr= 1;
- es->node= rn;
- es++;
- addedge(rn->v2, rn->v3, es);
- es->nr= 2;
- es->node= rn;
- es++;
- if(rp->type==3) {
- addedge(rn->v3, rn->v1, es);
- es->nr= 3;
- es->node= rn;
- es++;
- }
- else {
- addedge(rn->v3, rn->v4, es);
- es->nr= 3;
- es->node= rn;
- es++;
- addedge(rn->v4, rn->v1, es);
- es->nr= 4;
- es->node= rn;
- es++;
- }
- rp= rp->next;
- }
-
- qsort(esblock,tot,sizeof(EdSort),vergedge);
-
- es= esblock;
- while(tot>0) {
- if( es->v1== (es+1)->v1 ) {
- if( es->v2== (es+1)->v2 ) {
- setedge(es->node, (es+1)->node, es->nr, (es+1)->nr);
- tot--;
- es++;
- }
- }
- es++;
- tot--;
- }
-
- MEM_freeN(esblock);
-}
-
-static int materialIndex(Material *ma)
-{
- int i = 0;
- for(i=0;i< RG.totmat; i++)
- {
- if (RG.matar[i] == ma) {
- return i;
- }
- }
- return -1;
-}
-
-void rad_collect_meshes(Scene *scene, View3D *v3d)
-{
- extern Material defmaterial;
- Base *base;
- Object *ob;
- Mesh *me;
- MVert *mvert;
- MFace *mface;
- MTFace *tf, *tface;
- Material *ma = NULL, *noma= NULL;
- RPatch *rp;
- RNode *rn;
- VeNoCo *vnc, **nodevert;
- float *vd, *v1, *v2, *v3, *v4 = NULL;
- int a, b, offs, index, mfdatatot;
-
- if (v3d==NULL) {
- printf("Error, trying to collect radiosity meshes with no 3d view\n");
- return;
- }
-
- set_radglobal(scene);
-
- freeAllRad(scene);
-
- start_fastmalloc("Radiosity");
-
- /* count the number of verts */
- RG.totvert= 0;
- RG.totface= 0;
- base= (scene->base.first);
- while(base) {
- if(((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
- if(base->object->type==OB_MESH) {
- base->flag |= OB_RADIO;
- me= base->object->data;
- RG.totvert+= me->totvert;
- }
- }
- base= base->next;
- }
- if(RG.totvert==0) {
- if (!during_script()); //XXX error("No vertices");
- return;
- }
- vnc= RG.verts= MEM_callocN(RG.totvert*sizeof(VeNoCo), "radioverts");
-
- RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20f;
- RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20f;
-
- mfdatatot= 0;
-
- /* min-max and material array */
- base= (scene->base.first);
- while(base) {
- if( ((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
- if(base->object->type==OB_MESH) {
- me= base->object->data;
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- vd= mallocVert();
- VECCOPY(vd, mvert->co);
- /* Should make MTC its own module... */
- Mat4MulVecfl(base->object->obmat, vd);
-
- vnc->v= vd;
- for(b=0; b<3; b++) {
- RG.min[b]= MIN2(RG.min[b], vd[b]);
- RG.max[b]= MAX2(RG.max[b], vd[b]);
- }
- vnc++;
- }
-
- if(base->object->totcol==0) {
- if(RG.totmat<MAXMAT) {
- if(noma==NULL) {
- noma= add_material("RadioMat");
- RG.matar[RG.totmat]= noma;
- RG.totmat++;
- }
- }
- }
- else {
- for(a=0; a<base->object->totcol; a++) {
- if(RG.totmat >= MAXMAT) break;
-
- ma = give_current_material(base->object, a+1);
-
- if (materialIndex(ma)!=-1) break;
-
- RG.matar[RG.totmat]= ma;
- RG.totmat++;
- }
- }
-
- mfdatatot += me->totface;
- }
- }
- base= base->next;
- }
-
- RG.cent[0]= (RG.min[0]+ RG.max[0])/2;
- RG.cent[1]= (RG.min[1]+ RG.max[1])/2;
- RG.cent[2]= (RG.min[2]+ RG.max[2])/2;
- RG.size[0]= (RG.max[0]- RG.min[0]);
- RG.size[1]= (RG.max[1]- RG.min[1]);
- RG.size[2]= (RG.max[2]- RG.min[2]);
- RG.maxsize= MAX3(RG.size[0],RG.size[1],RG.size[2]);
-
- RG.mfdata= MEM_callocN(sizeof(CustomData), "radiomfdata");
- RG.mfdatanodes= MEM_mallocN(sizeof(RNode*)*mfdatatot, "radiomfdatanodes");
- RG.mfdatatot= mfdatatot;
-
- /* make patches */
-
- RG.totelem= 0;
- RG.totpatch= 0;
- RG.totlamp= 0;
- offs= 0;
-
- base= (scene->base.first);
- while(base) {
- if( ((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
- if(base->object->type==OB_MESH) {
- ob= base->object;
- me= ob->data;
- mface= me->mface;
- tface= me->mtface;
-
- index= -1;
-
- CustomData_merge(&me->fdata, RG.mfdata, CD_MASK_DERIVEDMESH,
- CD_DEFAULT, mfdatatot);
-
- for(a=0; a<me->totface; a++, mface++) {
- tf= tface? tface+a: NULL;
-
- if (tf && (tf->mode & TF_INVISIBLE))
- continue;
-
- rp= callocPatch();
- BLI_addtail(&(RG.patchbase), rp);
- rp->from= ob;
-
- if(mface->v4) rp->type= 4;
- else rp->type= 3;
-
- rp->first= rn= callocNode();
-
- if(mface->flag & ME_SMOOTH) rp->f1= RAD_NO_SPLIT;
-
- /* temporal: we store the venoco in the node */
- rn->v1= (float *)(RG.verts+mface->v1+offs);
- v1= (RG.verts+mface->v1+offs)->v;
- rn->v2= (float *)(RG.verts+mface->v2+offs);
- v2= (RG.verts+mface->v2+offs)->v;
- rn->v3= (float *)(RG.verts+mface->v3+offs);
- v3= (RG.verts+mface->v3+offs)->v;
-
- if(mface->v4) {
- rn->v4= (float *)(RG.verts+mface->v4+offs);
- v4= (RG.verts+mface->v4+offs)->v;
- }
- rn->par= rp;
- rn->f= RAD_PATCH; /* this node is a Patch */
- rn->type= rp->type;
-
- if(rn->type==4) {
- rp->area= AreaQ3Dfl(v1, v2, v3, v4);
- CalcNormFloat4(v1, v2, v3, v4, rp->norm);
- }
- else {
- rp->area= AreaT3Dfl(v1, v2, v3);
- CalcNormFloat(v1, v2, v3, rp->norm);
- }
-
- rn->area= rp->area;
-
- /* color and emit */
- if(mface->mat_nr != index) {
- index= mface->mat_nr;
- ma= give_current_material(ob, index+1);
- if(ma==0) ma= &defmaterial;
- }
- rp->ref[0]= ma->r;
- rp->ref[1]= ma->g;
- rp->ref[2]= ma->b;
-
- if(ma->emit) RG.totlamp++;
-
- rp->emit[0]= rp->emit[1]= rp->emit[2]= ma->emit;
- rp->emit[0]*= rp->ref[0];
- rp->emit[1]*= rp->ref[1];
- rp->emit[2]*= rp->ref[2];
-
-// uncommented, this is not satisfying, but i leave it in code for now (ton)
-// if(ma->translucency!=0.0) rn->f |= RAD_TWOSIDED;
-
- nodevert= (VeNoCo **)&(rn->v1);
- for(b=0; b<rp->type; b++) {
- rp->cent[0]+= (*nodevert)->v[0];
- rp->cent[1]+= (*nodevert)->v[1];
- rp->cent[2]+= (*nodevert)->v[2];
- nodevert++;
- }
- rp->cent[0]/= (float)rp->type;
- rp->cent[1]/= (float)rp->type;
- rp->cent[2]/= (float)rp->type;
-
- /* for reconstruction materials */
- rp->matindex= materialIndex(ma);
- if(rp->matindex==-1) rp->matindex= 1;
-
- /* these RNode's are stored now for later use in rad_addmesh
- they should not get deleted before that */
- rn->orig= RG.totelem;
- RG.mfdatanodes[RG.totelem]= rn;
-
- CustomData_copy_data(&me->fdata, RG.mfdata, a, RG.totelem, 1);
-
- RG.totelem++;
- RG.totpatch++;
- }
-
- offs+= me->totvert;
- }
- }
- base= base->next;
- }
-
- splitconnected();
- setedgepointers();
-
- makeGlobalElemArray();
- pseudoAmb();
- rad_setlimits(scene);
-}
-
-void setparelem(RNode *rn, RPatch *par)
-{
-
- if(rn->down1) {
- setparelem(rn->down1, par);
- setparelem(rn->down2, par);
- }
- else {
- rn->par= par;
- }
-}
-
-void countelem(RNode *rn)
-{
-
- if(rn->down1) {
- countelem(rn->down1);
- countelem(rn->down2);
- }
- else RG.totelem++;
-}
-
-void countglobaldata()
-{
- /* counts elements and patches*/
- RPatch *rp;
-
- RG.totelem= RG.totpatch= 0;
-
- rp= RG.patchbase.first;
- while(rp) {
- RG.totpatch++;
- countelem(rp->first);
- rp= rp->next;
- }
-}
-
-void addelem(RNode ***el, RNode *rn, RPatch *rp)
-{
- if(rn->down1) {
- addelem(el, rn->down1, rp);
- addelem(el, rn->down2, rp);
- }
- else {
- rn->par= rp;
- **el= rn;
- (*el)++;
- }
-}
-
-void makeGlobalElemArray()
-{
- /* always called when # of elements change */
- RPatch *rp;
- RNode **el;
-
- countglobaldata();
-
- if(RG.elem) MEM_freeN(RG.elem);
- if(RG.totelem) {
- el= RG.elem= MEM_mallocN(sizeof(void *)*RG.totelem, "makeGlobalElemArray");
- }
- else {
- RG.elem= 0;
- return;
- }
-
- /* recursive adding elements */
- rp= RG.patchbase.first;
- while(rp) {
- addelem(&el, rp->first, rp);
- rp= rp->next;
- }
-
- /* formfactor array */
- if(RG.formfactors) MEM_freeN(RG.formfactors);
- if(RG.totelem)
- RG.formfactors= MEM_mallocN(sizeof(float)*RG.totelem, "formfactors");
- else
- RG.formfactors= 0;
-}
-
-void splitpatch(RPatch *old) /* in case of overflow during shoot */
-{
- RNode *rn;
- float **fpp;
- RPatch *rp;
- int a;
-
- rn= old->first;
- if(rn->down1==0) return;
- rn= rn->down1;
-
- old->unshot[0]/=2.0;
- old->unshot[1]/=2.0;
- old->unshot[2]/=2.0;
- setnodeflags(old->first, 2, 0);
-
- rp= mallocPatch();
- *rp= *old;
- BLI_addhead(&RG.patchbase, rp);
- rp->first= rn;
- rp->area= rn->area;
- rp->cent[0]= rp->cent[1]= rp->cent[2]= 0.0;
- fpp= &(rn->v1);
- for(a=0; a<rp->type; a++) {
- rp->cent[0]+= (*fpp)[0];
- rp->cent[1]+= (*fpp)[1];
- rp->cent[2]+= (*fpp)[2];
- fpp++;
- }
- rp->cent[0]/=(float)rp->type;
- rp->cent[1]/=(float)rp->type;
- rp->cent[2]/=(float)rp->type;
-
- setparelem(rn, rp);
-
- rn= old->first->down2;
-
- rp= mallocPatch();
- *rp= *old;
- BLI_addhead(&RG.patchbase, rp);
- rp->first= rn;
- rp->area= rn->area;
- rp->cent[0]= rp->cent[1]= rp->cent[2]= 0.0;
- fpp= &(rn->v1);
- for(a=0; a<rp->type; a++) {
- rp->cent[0]+= (*fpp)[0];
- rp->cent[1]+= (*fpp)[1];
- rp->cent[2]+= (*fpp)[2];
- fpp++;
- }
- rp->cent[0]/=(float)rp->type;
- rp->cent[1]/=(float)rp->type;
- rp->cent[2]/=(float)rp->type;
-
- setparelem(rn, rp);
-
- BLI_remlink(&RG.patchbase, old);
- freePatch(old);
-}
-
-
-void addpatch(RPatch *old, RNode *rn)
-{
- float **fpp;
- RPatch *rp;
- int a;
-
- if(rn->down1) {
- addpatch(old, rn->down1);
- addpatch(old, rn->down2);
- }
- else {
- rp= mallocPatch();
- *rp= *old;
- BLI_addhead(&RG.patchbase, rp);
- rp->first= rn;
-
- rp->area= rn->area;
- rp->cent[0]= rp->cent[1]= rp->cent[2]= 0.0;
- fpp= &(rn->v1);
- for(a=0; a<rp->type; a++) {
- rp->cent[0]+= (*fpp)[0];
- rp->cent[1]+= (*fpp)[1];
- rp->cent[2]+= (*fpp)[2];
- fpp++;
- }
- rp->cent[0]/=(float)rp->type;
- rp->cent[1]/=(float)rp->type;
- rp->cent[2]/=(float)rp->type;
-
- rn->par= rp;
- }
-}
-
-void converttopatches()
-{
- /* chacks patches list, if node subdivided: new patch */
- RPatch *rp, *next;
-
- rp= RG.patchbase.first;
- while(rp) {
- next= rp->next;
- if(rp->first->down1) {
- addpatch(rp, rp->first);
- BLI_remlink(&RG.patchbase, rp);
- freePatch(rp);
- }
- rp= next;
- }
-
-}
-
-void subdiv_elements()
-{
- RNode **el, *rn;
- int a, toobig= 1;
-
- rad_init_energy();
-
- /* first maxsize elements */
-
- while(toobig) {
- toobig= 0;
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- if( rn->totrad[0]==0.0 && rn->totrad[1]==0.0 && rn->totrad[2]==0.0) {
- if(rn->area>RG.elemmin) {
- subdivideNode(rn, 0);
- if(rn->down1 ) {
- toobig= 1;
- if(rn->down1->area>RG.elemmin)
- subdivideNode( rn->down1, 0);
- if(rn->down2->area>RG.elemmin)
- subdivideNode( rn->down2, 0);
- }
- }
- }
- }
- if(toobig) makeGlobalElemArray();
- }
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- if( rn->totrad[0]==0.0 && rn->totrad[1]==0.0 && rn->totrad[2]==0.0) {
- subdivideNode(rn, 0);
- if( rn->down1 ) {
- subdivideNode( rn->down1, 0);
- subdivideNode( rn->down2, 0);
- }
- }
- }
- makeGlobalElemArray();
-}
-
-void subdividelamps()
-{
- RPatch *rp, *next;
-
- rp= RG.patchbase.first;
- while(rp) {
- next= rp->next;
- if(rp->emit[0]!=0.0 || rp->emit[1]!=0.0 || rp->emit[2]!=0.0) {
- subdivideNode( rp->first, 0);
- if(rp->first->down1) {
- subdivideNode(rp->first->down1, 0);
- subdivideNode(rp->first->down2, 0);
- }
-
- addpatch(rp, rp->first);
- BLI_remlink(&RG.patchbase, rp);
- freePatch(rp);
- }
- rp= next;
- }
-
-}
-
-void maxsizePatches()
-{
- RPatch *rp;
- int toobig= 1;
-
- while(toobig) {
- toobig= 0;
- rp= RG.patchbase.first;
- while(rp) {
- if(rp->area>RG.patchmax) {
- subdivideNode( rp->first, 0);
- if(rp->first->down1) toobig= 1;
- }
- rp= rp->next;
- }
-
- if(toobig) converttopatches();
- }
-
- /* count lamps */
- rp= RG.patchbase.first;
- RG.totlamp= 0;
- while(rp) {
- if(rp->emit[0]!=0.0 || rp->emit[1]!=0.0 || rp->emit[2]!=0.0) {
- RG.totlamp++;
- }
- rp= rp->next;
- }
- makeGlobalElemArray();
-}
-
-
-
diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c
deleted file mode 100644
index d33bbc90ee3..00000000000
--- a/source/blender/radiosity/intern/source/radrender.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/* ***************************************
- *
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/* radrender.c, aug 2003
- *
- * Most of the code here is copied from radiosity code, to optimize for renderfaces.
- * Shared function calls mostly reside in radfactors.c
- * No adaptive subdivision takes place
- *
- * - do_radio_render(); main call, extern
- * - initradfaces(); add radface structs in render faces, init radio globals
- * -
- * - initradiosity(); LUTs
- * - inithemiwindows();
- * - progressiverad(); main itteration loop
- * - hemi zbuffers
- * - calc rad factors
- *
- * - closehemiwindows();
- * - freeAllRad();
- * - make vertex colors
- *
- * - during render, materials use totrad as ambient replacement
- * - free radfaces
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_rand.h"
-
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-
-/* the radiosity module uses internal includes from render! */
-#include "renderpipeline.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-
-
-/* only needed now for a print, if its useful move to RG */
-static float maxenergy;
-
-/* find the face with maximum energy to become shooter */
-/* nb: _rr means rad-render version of existing radio call */
-static void findshoot_rr(Render *re, VlakRen **shoot_p, RadFace **shootrf_p)
-{
- RadFace *rf, *shootrf, **radface;
- ObjectRen *obr;
- VlakRen *vlr=NULL, *shoot;
- float energy;
- int a;
-
- shoot= NULL;
- shootrf= NULL;
- maxenergy= 0.0;
-
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- rf->flag &= ~RAD_SHOOT;
-
- energy= rf->unshot[0]*rf->area;
- energy+= rf->unshot[1]*rf->area;
- energy+= rf->unshot[2]*rf->area;
-
- if(energy>maxenergy) {
- shoot= vlr;
- shootrf= rf;
- maxenergy= energy;
- }
- }
- }
- }
-
- if(shootrf) {
- maxenergy/= RG.totenergy;
- if(maxenergy<RG.convergence) {
- *shoot_p= NULL;
- *shootrf_p= NULL;
- return;
- }
- shootrf->flag |= RAD_SHOOT;
- }
-
- *shoot_p= shoot;
- *shootrf_p= shootrf;
-}
-
-static void backface_test_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float tvec[3];
- int a;
-
- /* backface testing */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr != shoot && (radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- VecSubf(tvec, shootrf->cent, rf->cent);
-
- if(tvec[0]*rf->norm[0]+ tvec[1]*rf->norm[1]+ tvec[2]*rf->norm[2] < 0.0)
- rf->flag |= RAD_BACKFACE;
- }
- }
- }
-}
-
-static void clear_backface_test_rr(Render *re)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- int a;
-
- /* backface flag clear */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- rf->flag &= ~RAD_BACKFACE;
- }
- }
- }
-}
-
-extern RadView hemitop, hemiside; // radfactors.c
-
-/* hemi-zbuffering, delivers formfactors array */
-static void makeformfactors_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float len, vec[3], up[3], side[3], tar[5][3], *fp;
- int a;
-
- memset(RG.formfactors, 0, sizeof(float)*RG.totelem);
-
- /* set up hemiview */
- /* first: upvector for hemitop, we use diagonal hemicubes to prevent aliasing */
-
- VecSubf(vec, shoot->v1->co, shootrf->cent);
- Crossf(up, shootrf->norm, vec);
- len= Normalize(up);
-
- VECCOPY(hemitop.up, up);
- VECCOPY(hemiside.up, shootrf->norm);
-
- Crossf(side, shootrf->norm, up);
-
- /* five targets */
- VecAddf(tar[0], shootrf->cent, shootrf->norm);
- VecAddf(tar[1], shootrf->cent, up);
- VecSubf(tar[2], shootrf->cent, up);
- VecAddf(tar[3], shootrf->cent, side);
- VecSubf(tar[4], shootrf->cent, side);
-
- /* camera */
- VECCOPY(hemiside.cam, shootrf->cent);
- VECCOPY(hemitop.cam, shootrf->cent);
-
- /* do it! */
- VECCOPY(hemitop.tar, tar[0]);
- hemizbuf(&hemitop);
-
- for(a=1; a<5; a++) {
- VECCOPY(hemiside.tar, tar[a]);
- hemizbuf(&hemiside);
- }
-
- /* convert factors to real radiosity */
- fp= RG.formfactors;
-
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- if(*fp!=0.0 && rf->area!=0.0) {
- *fp *= shootrf->area/rf->area;
- if(*fp>1.0) *fp= 1.0001;
- }
- fp++;
- }
- }
- }
-}
-
-/* based at RG.formfactors array, distribute shoot energy over other faces */
-static void applyformfactors_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float *fp, *ref, unr, ung, unb, r, g, b;
- int a;
-
- unr= shootrf->unshot[0];
- ung= shootrf->unshot[1];
- unb= shootrf->unshot[2];
-
- fp= RG.formfactors;
-
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- if(*fp!= 0.0) {
-
- ref= &(vlr->mat->r);
-
- r= (*fp)*unr*ref[0];
- g= (*fp)*ung*ref[1];
- b= (*fp)*unb*ref[2];
-
- // if(rf->flag & RAD_BACKFACE) {
-
- rf->totrad[0]+= r;
- rf->totrad[1]+= g;
- rf->totrad[2]+= b;
-
- rf->unshot[0]+= r;
- rf->unshot[1]+= g;
- rf->unshot[2]+= b;
- }
- fp++;
- }
- }
- }
- /* shoot energy has been shot */
- shootrf->unshot[0]= shootrf->unshot[1]= shootrf->unshot[2]= 0.0;
-}
-
-
-/* main loop for itterations */
-static void progressiverad_rr(Render *re)
-{
- VlakRen *shoot;
- RadFace *shootrf;
- float unshot[3];
- int it= 0;
-
- findshoot_rr(re, &shoot, &shootrf);
- while( shoot ) {
-
- /* backfaces receive no energy, but are zbuffered... */
- backface_test_rr(re, shoot, shootrf);
-
- /* ...unless it's two sided */
- if(shootrf->flag & RAD_TWOSIDED) {
- VECCOPY(unshot, shootrf->unshot);
- VecNegf(shootrf->norm);
- makeformfactors_rr(re, shoot, shootrf);
- applyformfactors_rr(re, shoot, shootrf);
- VecNegf(shootrf->norm);
- VECCOPY(shootrf->unshot, unshot);
- }
-
- /* hemi-zbuffers */
- makeformfactors_rr(re, shoot, shootrf);
- /* based at RG.formfactors array, distribute shoot energy over other faces */
- applyformfactors_rr(re, shoot, shootrf);
-
- it++;
- re->timecursor(re->tch, it);
-
- clear_backface_test_rr(re);
-
- if(re->test_break(re->tbh)) break;
- if(RG.maxiter && RG.maxiter<=it) break;
-
- findshoot_rr(re, &shoot, &shootrf);
- }
- printf(" Unshot energy:%f\n", 1000.0*maxenergy);
-
- re->timecursor(re->tch, re->scene->r.cfra);
-}
-
-static RadFace *radfaces=NULL;
-
-static void initradfaces(Render *re)
-{
- ObjectRen *obr;
- VlakRen *vlr= NULL;
- RadFace *rf, **radface;
- int a, b;
-
- /* globals */
- RG.totenergy= 0.0;
- RG.totpatch= 0; // we count initial emittors here
- RG.totelem= 0; // total # faces are put here (so we can use radfactors.c calls)
- /* size is needed for hemicube clipping */
- RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20;
- RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20;
-
- /* count first for fast malloc */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if(vlr->mat->mode & MA_RADIO) {
- if(vlr->mat->emit > 0.0) {
- RG.totpatch++;
- }
- RG.totelem++;
- }
- }
- }
-
-printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
- if(RG.totelem==0 || RG.totpatch==0) return;
-
- /* make/init radfaces */
- rf=radfaces= MEM_callocN(RG.totelem*sizeof(RadFace), "radfaces");
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if(vlr->mat->mode & MA_RADIO) {
-
- /* during render, vlr->n gets flipped/corrected, we cannot have that */
- if (obr->ob->transflag & OB_NEG_SCALE){
- /* The object has negative scale that will cause the normals to flip.
- To counter this unwanted normal flip, swap vertex 2 and 4 for a quad
- or vertex 2 and 3 (see flip_face) for a triangle in the call to CalcNormFloat4
- in order to flip the normals back to the way they were in the original mesh. */
- if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v4->co, vlr->v3->co, vlr->v2->co, rf->norm);
- else CalcNormFloat(vlr->v1->co, vlr->v3->co, vlr->v2->co, rf->norm);
- }else{
- if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
- else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
- }
-
- rf->totrad[0]= vlr->mat->emit*vlr->mat->r;
- rf->totrad[1]= vlr->mat->emit*vlr->mat->g;
- rf->totrad[2]= vlr->mat->emit*vlr->mat->b;
- VECCOPY(rf->unshot, rf->totrad);
-
- if(vlr->v4) {
- rf->area= AreaQ3Dfl(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co);
- CalcCent4f(rf->cent, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co);
- }
- else {
- rf->area= AreaT3Dfl(vlr->v1->co, vlr->v2->co, vlr->v3->co);
- CalcCent3f(rf->cent, vlr->v1->co, vlr->v2->co, vlr->v3->co);
- }
-
- RG.totenergy+= rf->unshot[0]*rf->area;
- RG.totenergy+= rf->unshot[1]*rf->area;
- RG.totenergy+= rf->unshot[2]*rf->area;
-
- for(b=0; b<3; b++) {
- RG.min[b]= MIN2(RG.min[b], rf->cent[b]);
- RG.max[b]= MAX2(RG.max[b], rf->cent[b]);
- }
-
- // uncommented; this isnt satisfying, but i leave it in the code for now (ton)
- // if(vlr->mat->translucency!=0.0) rf->flag |= RAD_TWOSIDED;
-
- radface=RE_vlakren_get_radface(obr, vlr, 1);
- *radface= rf++;
- }
- }
- }
- RG.size[0]= (RG.max[0]- RG.min[0]);
- RG.size[1]= (RG.max[1]- RG.min[1]);
- RG.size[2]= (RG.max[2]- RG.min[2]);
- RG.maxsize= MAX3(RG.size[0],RG.size[1],RG.size[2]);
-
- /* formfactor array */
- if(RG.formfactors) MEM_freeN(RG.formfactors);
- if(RG.totelem)
- RG.formfactors= MEM_mallocN(sizeof(float)*RG.totelem, "formfactors");
- else
- RG.formfactors= NULL;
-
-}
-
-static void vecaddfac(float *vec, float *v1, float *v2, float fac)
-{
- vec[0]= v1[0] + fac*v2[0];
- vec[1]= v1[1] + fac*v2[1];
- vec[2]= v1[2] + fac*v2[2];
-
-}
-
-/* unused now, doesnt work..., find it in cvs of nov 2005 or older */
-/* static void filter_rad_values(void) */
-
-
-static void make_vertex_rad_values(Render *re)
-{
- ObjectRen *obr;
- VertRen *v1=NULL;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float *col;
- int a;
-
- RG.igamma= 1.0/RG.gamma;
- RG.radfactor= RG.radfac*pow(64*64, RG.igamma)/128.0; /* compatible with radio-tool */
-
- /* accumulate vertexcolors */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
-
- /* apply correction */
- rf->totrad[0]= RG.radfactor*pow( rf->totrad[0], RG.igamma);
- rf->totrad[1]= RG.radfactor*pow( rf->totrad[1], RG.igamma);
- rf->totrad[2]= RG.radfactor*pow( rf->totrad[2], RG.igamma);
-
- /* correct rf->rad values for color */
- if(vlr->mat->r > 0.0) rf->totrad[0]/= vlr->mat->r;
- if(vlr->mat->g > 0.0) rf->totrad[1]/= vlr->mat->g;
- if(vlr->mat->b > 0.0) rf->totrad[2]/= vlr->mat->b;
-
- col= RE_vertren_get_rad(obr, vlr->v1, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
-
- col= RE_vertren_get_rad(obr, vlr->v2, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
-
- col= RE_vertren_get_rad(obr, vlr->v3, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
-
- if(vlr->v4) {
- col= RE_vertren_get_rad(obr, vlr->v4, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
- }
- }
- }
-
- /* make vertex colors */
- for(a=0; a<obr->totvert; a++) {
- if((a & 255)==0) v1= RE_findOrAddVert(obr, a); else v1++;
-
- col= RE_vertren_get_rad(obr, v1, 0);
- if(col && col[3]>0.0) {
- col[0]/= col[3];
- col[1]/= col[3];
- col[2]/= col[3];
- }
- }
- }
-}
-
-/* main call, extern */
-void do_radio_render(Render *re)
-{
- if(re->scene->radio==NULL) add_radio(re->scene);
- freeAllRad(re->scene); /* just in case radio-tool is still used */
-
- set_radglobal(re->scene); /* init the RG struct */
- RG.re= re; /* only used by hemizbuf(), prevents polluting radio code all over */
-
- initradfaces(re); /* add radface structs to render faces */
- if(RG.totenergy>0.0) {
-
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views, need RG.maxsize for clipping */
-
- progressiverad_rr(re); /* main radio loop */
-
- make_vertex_rad_values(re); /* convert face energy to vertex ones */
-
- }
-
- freeAllRad(re->scene); /* luts, hemis, sets vars at zero */
-}
-
-/* free call, after rendering, extern */
-void end_radio_render(void)
-{
- if(radfaces) MEM_freeN(radfaces);
- radfaces= NULL;
-}
-
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index 20eea0c98bd..15b59f2c8cc 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -47,7 +47,8 @@ struct Render;
struct MTex;
struct ImBuf;
-void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re);
+// RADIO REMOVED, Maybe this will be useful later
+//void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re);
/* particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */
int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta);
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 98e5819c0d3..a00cd2211fc 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -104,7 +104,6 @@
#include "rendercore.h"
#include "renderdatabase.h"
#include "renderpipeline.h"
-#include "radio.h"
#include "shadbuf.h"
#include "shading.h"
#include "strand.h"
@@ -1886,6 +1885,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(psys_get_particle_state(re->scene,ob,psys,a,&state,0)==0)
continue;
+ if(psys->parent)
+ Mat4MulVecfl(psys->parent->obmat, state.co);
+
VECCOPY(loc,state.co);
if(part->ren_as!=PART_DRAW_BB)
MTC_Mat4MulVecfl(re->viewmat,loc);
@@ -4308,8 +4310,9 @@ void RE_Database_Free(Render *re)
}
free_mesh_orco_hash(re);
-
+#if 0 /* radio can be redone better */
end_radio_render();
+#endif
end_render_materials();
end_render_textures();
@@ -4736,10 +4739,11 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view)
/* yafray: 'direct' radiosity, environment maps and raytree init not needed for yafray render */
/* although radio mode could be useful at some point, later */
if (re->r.renderer==R_INTERN) {
+#if 0 /* RADIO was removed */
/* RADIO (uses no R anymore) */
if(!re->test_break(re->tbh))
if(re->r.mode & R_RADIO) do_radio_render(re);
-
+#endif
/* raytree */
if(!re->test_break(re->tbh)) {
if(re->r.mode & R_RAYTRACE) {
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 07560edb76b..5eec13ed7fe 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -46,6 +46,7 @@
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */
+#include "BKE_pointcache.h"
#include "MEM_guardedalloc.h"
@@ -61,7 +62,6 @@
#include "intern/openexr/openexr_multi.h"
#include "RE_pipeline.h"
-#include "radio.h"
/* internal */
#include "render_types.h"
@@ -2413,6 +2413,20 @@ static int is_rendering_allowed(Render *re)
return 1;
}
+static void update_physics_cache(Render *re, Scene *scene)
+{
+ PTCacheBaker baker;
+
+ baker.scene = scene;
+ baker.pid = NULL;
+ baker.bake = 0;
+ baker.render = 1;
+ baker.break_test = re->test_break;
+ baker.break_data = re->tbh;
+ baker.progressbar = NULL;
+
+ BKE_ptcache_make_cache(&baker);
+}
/* evaluating scene options for general Blender render */
static int render_initialize_from_scene(Render *re, Scene *scene, int anim)
{
@@ -2450,6 +2464,9 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim)
/* check all scenes involved */
tag_scenes_for_render(re);
+
+ /* make sure dynamics are up to date */
+ update_physics_cache(re, scene);
if(scene->r.scemode & R_SINGLE_LAYER)
push_render_result(re);
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index b68cecce7bd..21c3977fc0b 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -49,14 +49,12 @@
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_material_types.h"
#include "BKE_global.h"
#include "BKE_material.h"
#include "BKE_utildefines.h"
-#include "radio_types.h"
-#include "radio.h" /* needs RG, some root data for radiosity */
-
#include "RE_render_ext.h"
/* local includes */
@@ -2301,110 +2299,6 @@ static int hashlist_projectvert(float *v1, float winmat[][4], float *hoco)
return buck->clip;
}
-/* used for booth radio 'tool' as during render */
-void RE_zbufferall_radio(struct RadView *vw, RNode **rg_elem, int rg_totelem, Render *re)
-{
- ZSpan zspan;
- float hoco[4][4], winmat[4][4];
- int a, zvlnr;
- int c1, c2, c3, c4= 0;
-
- if(rg_totelem==0) return;
-
- hashlist_projectvert(NULL, winmat, NULL);
-
- /* needed for projectvert */
- MTC_Mat4MulMat4(winmat, vw->viewmat, vw->winmat);
-
- /* 1.0f for clipping in clippyra()... bad stuff actually */
- zbuf_alloc_span(&zspan, vw->rectx, vw->recty, 1.0f);
- zspan.zmulx= ((float)vw->rectx)/2.0;
- zspan.zmuly= ((float)vw->recty)/2.0;
- zspan.zofsx= -0.5f;
- zspan.zofsy= -0.5f;
-
- /* the buffers */
- zspan.rectz= (int *)vw->rectz;
- zspan.rectp= (int *)vw->rect;
- zspan.recto= MEM_callocN(sizeof(int)*vw->rectx*vw->recty, "radiorecto");
- fillrect(zspan.rectz, vw->rectx, vw->recty, 0x7FFFFFFF);
- fillrect(zspan.rectp, vw->rectx, vw->recty, 0xFFFFFF);
-
- /* filling methods */
- zspan.zbuffunc= zbuffillGL4;
-
- if(rg_elem) { /* radio tool */
- RNode **re, *rn;
-
- re= rg_elem;
- re+= (rg_totelem-1);
- for(a= rg_totelem-1; a>=0; a--, re--) {
- rn= *re;
- if( (rn->f & RAD_SHOOT)==0 ) { /* no shootelement */
-
- if( rn->f & RAD_TWOSIDED) zvlnr= a;
- else if( rn->f & RAD_BACKFACE) zvlnr= 0xFFFFFF;
- else zvlnr= a;
-
- c1= hashlist_projectvert(rn->v1, winmat, hoco[0]);
- c2= hashlist_projectvert(rn->v2, winmat, hoco[1]);
- c3= hashlist_projectvert(rn->v3, winmat, hoco[2]);
-
- if(rn->v4) {
- c4= hashlist_projectvert(rn->v4, winmat, hoco[3]);
- }
-
- if(rn->v4)
- zbufclip4(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- else
- zbufclip(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], c1, c2, c3);
- }
- }
- }
- else { /* radio render */
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace **radface, *rf;
- int totface=0;
-
- /* note: radio render doesn't support duplis */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- hashlist_projectvert(NULL, NULL, NULL); /* clear hashlist */
-
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- if( (rf->flag & RAD_SHOOT)==0 ) { /* no shootelement */
-
- if( rf->flag & RAD_TWOSIDED) zvlnr= totface;
- else if( rf->flag & RAD_BACKFACE) zvlnr= 0xFFFFFF; /* receives no energy, but is zbuffered */
- else zvlnr= totface;
-
- c1= hashlist_projectvert(vlr->v1->co, winmat, hoco[0]);
- c2= hashlist_projectvert(vlr->v2->co, winmat, hoco[1]);
- c3= hashlist_projectvert(vlr->v3->co, winmat, hoco[2]);
-
- if(vlr->v4) {
- c4= hashlist_projectvert(vlr->v4->co, winmat, hoco[3]);
- }
-
- if(vlr->v4)
- zbufclip4(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- else
- zbufclip(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], c1, c2, c3);
- }
- totface++;
- }
- }
- }
- }
-
- MEM_freeN(zspan.recto);
- zbuf_free_span(&zspan);
-}
-
void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int size, float jitx, float jity)
{
ZbufProjectCache cache[ZBUF_PROJECT_CACHE_SIZE];
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 739cfbcc1ac..9b987cdfa51 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -58,37 +58,6 @@ enum {
WM_OP_EXEC_SCREEN
};
-/* ************** wmEvent ************************ */
-
-/* each event should have full modifier state */
-/* event comes from eventmanager and from keymap */
-typedef struct wmEvent {
- struct wmEvent *next, *prev;
-
- short type; /* event code itself (short, is also in keymap) */
- short val; /* press, release, scrollvalue */
- short x, y; /* mouse pointer position, screen coord */
- short mval[2]; /* region mouse position, name convention pre 2.5 :) */
- short prevx, prevy; /* previous mouse pointer position */
- short unicode; /* future, ghost? */
- char ascii; /* from ghost */
- char pad;
-
- /* modifier states */
- short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
- short keymodifier; /* rawkey modifier */
-
- /* keymap item, set by handler (weak?) */
- const char *keymap_idname;
-
- /* custom data */
- short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
- void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
- short customdatafree;
-
-} wmEvent;
-
-
/* ************** wmKeyMap ************************ */
/* modifier */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index adbc43e439d..0bc35ffa9b2 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -58,8 +58,6 @@
#include "RE_pipeline.h" /* RE_ free stuff */
-#include "radio.h"
-
#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
#endif
@@ -196,9 +194,6 @@ void WM_exit(bContext *C)
// BIF_freeRetarget();
BIF_freeTemplates(C);
BIF_freeSketch(C);
-
- /* Context should still working here. but radio tool needs cleaning... */
- freeAllRad(CTX_data_scene(C));
free_ttfont(); /* bke_font.h */
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 7528321c7c5..85028e3ea1a 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -44,6 +44,7 @@
#include "RNA_access.h"
#include "RNA_types.h"
+#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -155,313 +156,9 @@ ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, int spacei
char *WM_key_event_string(short type)
{
- /* not returned: CAPSLOCKKEY, UNKNOWNKEY, COMMANDKEY, GRLESSKEY */
-
- switch(type) {
- case AKEY:
- return "A";
- break;
- case BKEY:
- return "B";
- break;
- case CKEY:
- return "C";
- break;
- case DKEY:
- return "D";
- break;
- case EKEY:
- return "E";
- break;
- case FKEY:
- return "F";
- break;
- case GKEY:
- return "G";
- break;
- case HKEY:
- return "H";
- break;
- case IKEY:
- return "I";
- break;
- case JKEY:
- return "J";
- break;
- case KKEY:
- return "K";
- break;
- case LKEY:
- return "L";
- break;
- case MKEY:
- return "M";
- break;
- case NKEY:
- return "N";
- break;
- case OKEY:
- return "O";
- break;
- case PKEY:
- return "P";
- break;
- case QKEY:
- return "Q";
- break;
- case RKEY:
- return "R";
- break;
- case SKEY:
- return "S";
- break;
- case TKEY:
- return "T";
- break;
- case UKEY:
- return "U";
- break;
- case VKEY:
- return "V";
- break;
- case WKEY:
- return "W";
- break;
- case XKEY:
- return "X";
- break;
- case YKEY:
- return "Y";
- break;
- case ZKEY:
- return "Z";
- break;
-
- case ZEROKEY:
- return "Zero";
- break;
- case ONEKEY:
- return "One";
- break;
- case TWOKEY:
- return "Two";
- break;
- case THREEKEY:
- return "Three";
- break;
- case FOURKEY:
- return "Four";
- break;
- case FIVEKEY:
- return "Five";
- break;
- case SIXKEY:
- return "Six";
- break;
- case SEVENKEY:
- return "Seven";
- break;
- case EIGHTKEY:
- return "Eight";
- break;
- case NINEKEY:
- return "Nine";
- break;
-
- case LEFTCTRLKEY:
- return "Leftctrl";
- break;
- case LEFTALTKEY:
- return "Leftalt";
- break;
- case RIGHTALTKEY:
- return "Rightalt";
- break;
- case RIGHTCTRLKEY:
- return "Rightctrl";
- break;
- case RIGHTSHIFTKEY:
- return "Rightshift";
- break;
- case LEFTSHIFTKEY:
- return "Leftshift";
- break;
-
- case ESCKEY:
- return "Esc";
- break;
- case TABKEY:
- return "Tab";
- break;
- case RETKEY:
- return "Ret";
- break;
- case SPACEKEY:
- return "Space";
- break;
- case LINEFEEDKEY:
- return "Linefeed";
- break;
- case BACKSPACEKEY:
- return "Backspace";
- break;
- case DELKEY:
- return "Del";
- break;
- case SEMICOLONKEY:
- return "Semicolon";
- break;
- case PERIODKEY:
- return "Period";
- break;
- case COMMAKEY:
- return "Comma";
- break;
- case QUOTEKEY:
- return "Quote";
- break;
- case ACCENTGRAVEKEY:
- return "Accentgrave";
- break;
- case MINUSKEY:
- return "Minus";
- break;
- case SLASHKEY:
- return "Slash";
- break;
- case BACKSLASHKEY:
- return "Backslash";
- break;
- case EQUALKEY:
- return "Equal";
- break;
- case LEFTBRACKETKEY:
- return "Leftbracket";
- break;
- case RIGHTBRACKETKEY:
- return "Rightbracket";
- break;
-
- case LEFTARROWKEY:
- return "Leftarrow";
- break;
- case DOWNARROWKEY:
- return "Downarrow";
- break;
- case RIGHTARROWKEY:
- return "Rightarrow";
- break;
- case UPARROWKEY:
- return "Uparrow";
- break;
-
- case PAD2:
- return "Numpad 2";
- break;
- case PAD4:
- return "Numpad 4";
- break;
- case PAD6:
- return "Numpad 6";
- break;
- case PAD8:
- return "Numpad 8";
- break;
- case PAD1:
- return "Numpad 1";
- break;
- case PAD3:
- return "Numpad 3";
- break;
- case PAD5:
- return "Numpad 5";
- break;
- case PAD7:
- return "Numpad 7";
- break;
- case PAD9:
- return "Numpad 9";
- break;
-
- case PADPERIOD:
- return "Numpad .";
- break;
- case PADSLASHKEY:
- return "Numpad /";
- break;
- case PADASTERKEY:
- return "Numpad *";
- break;
-
- case PAD0:
- return "Numpad 0";
- break;
- case PADMINUS:
- return "Numpad -";
- break;
- case PADENTER:
- return "Numpad Enter";
- break;
- case PADPLUSKEY:
- return "Numpad +";
- break;
-
- case F1KEY:
- return "F1";
- break;
- case F2KEY:
- return "F2";
- break;
- case F3KEY:
- return "F3";
- break;
- case F4KEY:
- return "F4";
- break;
- case F5KEY:
- return "F5";
- break;
- case F6KEY:
- return "F6";
- break;
- case F7KEY:
- return "F7";
- break;
- case F8KEY:
- return "F8";
- break;
- case F9KEY:
- return "F9";
- break;
- case F10KEY:
- return "F10";
- break;
- case F11KEY:
- return "F11";
- break;
- case F12KEY:
- return "F12";
- break;
-
- case PAUSEKEY:
- return "Pause";
- break;
- case INSERTKEY:
- return "Insert";
- break;
- case HOMEKEY:
- return "Home";
- break;
- case PAGEUPKEY:
- return "Pageup";
- break;
- case PAGEDOWNKEY:
- return "Pagedown";
- break;
- case ENDKEY:
- return "End";
- break;
- }
+ const char *name= NULL;
+ if(RNA_enum_name(event_type_items, (int)type, &name))
+ return name;
return "";
}