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:
authorCampbell Barton <ideasman42@gmail.com>2009-06-21 20:18:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-21 20:18:38 +0400
commit8ead648fd1ca35f02901764445afc7b675524b67 (patch)
tree48a86dbc7ad44553d6123637eae5f925404512cf /source/blender
parentde77b4a9b36cc0f12c8bd458c4a7f662caec38ac (diff)
Spring Cleaning
* removed radiosity render code, DNA and RNA (left in radio render pass options), we'll get GI to replace this probably, better allow baking to vertex colors for people who used this. * removed deprecated solid physics library, sumo integrations and qhull, a dependency * removed ODE, was no longer being build or supported * remove BEOS and AMIGA defines and references in Makefiles.
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_utildefines.h2
-rw-r--r--source/blender/blenkernel/intern/blender.c1
-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.c2
-rw-r--r--source/blender/blenloader/intern/writefile.c1
-rw-r--r--source/blender/blenpluginapi/intern/Makefile4
-rw-r--r--source/blender/editors/space_buttons/SConscript3
-rw-r--r--source/blender/editors/space_info/SConscript3
-rw-r--r--source/blender/editors/space_logic/SConscript3
-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_radio_types.h62
-rw-r--r--source/blender/makesdna/DNA_scene_types.h4
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
-rw-r--r--source/blender/makesrna/intern/makesrna.c1
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-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_world.c2
-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.c7
-rw-r--r--source/blender/render/intern/source/pipeline.c1
-rw-r--r--source/blender/render/intern/source/zbuf.c108
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c5
44 files changed, 15 insertions, 5995 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_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 6584af085cd..8043eb74749 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -130,7 +130,7 @@
#define IN_RANGE(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
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/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 77e256f1435..48aa3f6a3b7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3941,8 +3941,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) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 9ef062bd7b6..172c081570b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1600,7 +1600,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/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_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/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_radio_types.h b/source/blender/makesdna/DNA_radio_types.h
deleted file mode 100644
index 4219bf59b93..00000000000
--- a/source/blender/makesdna/DNA_radio_types.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * radio_types.h dec 2000 Nzc
- *
- * All type defs for the Blender core.
- *
- * $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 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
-
-/* flag */
-#define RAD_SHOWLIMITS 1
-#define RAD_SHOWZ 2
-
-#endif
-
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 7391201776e..4605d1f31e2 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/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/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 75293d83346..e7ca3fc5932 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1853,7 +1853,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_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 362217e3123..7538f103245 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -145,7 +145,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_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_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/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 8423b5d271c..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"
@@ -4311,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();
@@ -4739,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 f7aae88519f..5eec13ed7fe 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -62,7 +62,6 @@
#include "intern/openexr/openexr_multi.h"
#include "RE_pipeline.h"
-#include "radio.h"
/* internal */
#include "render_types.h"
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/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 */