[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11303] branches/soc-2007-joeedh/source/ blender: Pre-merge commit.
Joseph Eagar
joeedh at gmail.com
Wed Jul 18 16:53:18 CEST 2007
Revision: 11303
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11303
Author: joeedh
Date: 2007-07-18 16:53:17 +0200 (Wed, 18 Jul 2007)
Log Message:
-----------
Pre-merge commit.
Btw, nothing works. Quite literally.
Joe
Modified Paths:
--------------
branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_file.c
branches/soc-2007-joeedh/source/blender/blenlib/BLI_blenlib.h
branches/soc-2007-joeedh/source/blender/blenlib/intern/util.c
branches/soc-2007-joeedh/source/blender/makesdna/DNA_lamp_types.h
branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c
branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2007-07-18 10:44:24 UTC (rev 11302)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2007-07-18 14:53:17 UTC (rev 11303)
@@ -5,49 +5,43 @@
struct MemArena;
-typedef struct DSMSample {
+typedef struct DSMLayerSample {
float clr[4];
int depth;
-} DSMSample;
+ /*original number of samples between this layer and the previous one.*/
+ int orig_totsamples;
+} DSMLayerSample;
+
#define MAX_DSMLAYERS 16
/*ok heres how it works. A "layer"
is the total number of samples going from light
energy 1.0 to 0.0, then repeating.*/
-typedef struct DSMLayerArray {
- /*complete total number of samples in
- each layer*/
+typedef struct DSMFunction {
+ int totsamples, zmin, zmax;
+
+ /*consequtive array of samples*/
+ DSMLayerSample *samples;
+} DSMFunction;
+
+/*
+typedef struct DSMFunctionArray {
+ DSMFunction *layers;
+
+ //complete total number of samples in all layers
int totsamples;
int totlayers;
- int zmin, zmax;
- int layeroffsets[MAX_DSMLAYERS];
+ int zmin, zmax
+} DSMFunctionArray;
+*/
- /*consequtive array of samples.
- store DSMSample(depth is length of layer),
- DSMSamples. . ., DSMSample (depth is length of
- layer), DSMSamples. . ., etc.*/
- DSMSample *samples;
-} DSMLayerArray;
-
/*Each tile has its own memarena to work better with caching.*/
typedef struct DSMTile {
TCS_Tile tile;
-
- /*the first element of the arrays pointed to by
- depth_rect is the length of the pixel depth
- array, and is 1/4th the size of the pixel color array (since it
- stores rgba colors of course)
-
- at the moment alpha is stored as 0 == shadow, 1 == no shadow, due
- to how I've managed to paint myself into a corner where that is
- concerned (I originally wanted 0=shadow, 1=no shadow like alpha
- in materials work).
- */
- //float **color_rect; /* includes alpha */
- //unsigned int **depth_rect;
+ DSMFunction **layer_rect;
- DSMSample **sample_rect; /*first entry's depth is the length of the pixel arra*/
+ DSMLayerSample **sample_rect; /*first entry's depth is the length of the pixel array*/
/*tile coordinates inside poly_rect.
Note: this is *not* in image space units!
@@ -61,7 +55,7 @@
typedef struct DSMBuffer {
TCS_TileBuffer buffer;
- DSMTile *poly_rect;
+ DSMTile *vfunc_rect; /*visibility functions*/
int sizex, sizey;
int tilex, tiley; /*total number of tiles in x and y dimensions.*/
@@ -70,8 +64,11 @@
a user-definable size.*/
int tsizex, tsizey;
int max_depth; /*the maximum number of samples in a single pixel*/
+ int max_layers; /*maximum number of extra visibility functions to store for soft sampling*/
} DSMBuffer;
+#define MAX_SAMPLELAYERS 32
+
/*private*/
/*ok, this was meant for using TCS_MakeBuffer, but that's kindof a bad idea really so
instead the dsm creation function uses TCS_InitBuffer*/
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c 2007-07-18 10:44:24 UTC (rev 11302)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c 2007-07-18 14:53:17 UTC (rev 11303)
@@ -341,7 +341,9 @@
TCS_Tile *tile, *prev;
unsigned long mem, memconfirm, i=0;
- //return;
+ /*disable cacher for now*/
+ return;
+
BASSERT(pool);
if (!pool) return;
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c 2007-07-18 10:44:24 UTC (rev 11302)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c 2007-07-18 14:53:17 UTC (rev 11303)
@@ -1,5 +1,5 @@
/**
- * $Id: tcs_dsm.c 10648 2007-05-03 21:37:52Z blendix $
+ * $Id: tcs_dsm.c 10648 2007-05-03 21:37:52Z joeedh $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * The Original Code is Copyright (C) 2007 by Joseph Eagar.
+ * The Original Code is Copyright (C) 2007 by the Blender Foundation.
*
* Contributor(s): Joseph Eagar
*
@@ -57,7 +57,7 @@
static void dsm_loadtile(TCS_Tile *tself, TCS_File *file)
{
DSMTile *self = (DSMTile*) tself;
- DSMSample *sample;
+ DSMLayerSample *sample;
unsigned short sclr[4];
unsigned int totdepth;
int x, y, i, j, tot=0, magic;
@@ -93,7 +93,7 @@
//fflush(stderr);
//}
- sample = self->sample_rect[y*self->sizex+x] = BLI_memarena_alloc(self->arena, sizeof(DSMSample)*(totdepth+1));
+ sample = self->sample_rect[y*self->sizex+x] = BLI_memarena_alloc(self->arena, sizeof(DSMLayerSample)*(totdepth+1));
sample[0].depth = totdepth;
sample++;
@@ -119,7 +119,7 @@
static unsigned int dsm_savetile(struct TCS_Tile *tself, TCS_File *file, unsigned long curpos)
{
DSMTile *self = (DSMTile*) tself;
- DSMSample *sample, *first;
+ DSMLayerSample *sample, *first;
unsigned short sclr[4];
unsigned long fend;
int x, y, j, tot=0, num;
@@ -210,22 +210,10 @@
unsigned int dsm_gettilemem(TCS_Tile *tself)
{
DSMTile *tile = (DSMTile*)tself;
- DSMSample *sample;
+ DSMLayerSample *sample;
unsigned int mem = 0, x, y;
- mem += sizeof(int)*2; /*magic number + total number of elements*/
- if (tself->is_compressed) return tself->len;
-
- for (y=0; y<tile->sizey; y++) {
- for (x=0; x<tile->sizex; x++) {
- sample = tile->sample_rect[y*tile->sizex+x];
-
- /*sizeof(int)*3 is x, y, and total number of elements*/
- if (sample) mem += sizeof(int)*3 + sizeof(short)*4*sample[0].depth + sizeof(int)*sample[0].depth;
- }
- }
-
- return mem;
+ return 0;
}
void _DSM_maketile(TCS_TileBuffer *self, TCS_TilePool *pool, TCS_Tile *vtile)
@@ -293,7 +281,7 @@
//printf("getting a tile! x: %d, y: %d, tself: %p, buf: %p\n", x, y, tself, buf);
- return &buf->poly_rect[y*buf->tilex+x];
+ return &buf->vfunc_rect[y*buf->tilex+x];
}
/*I'll just not fill in this function, since I don't see any particular reason to*/
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_file.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_file.c 2007-07-18 10:44:24 UTC (rev 11302)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_file.c 2007-07-18 14:53:17 UTC (rev 11303)
@@ -1,5 +1,5 @@
/**
- * $Id: tcs_tile.c 10648 2007-05-03 21:37:52Z blendix $
+ * $Id: tcs_file.c 10648 2007-05-03 21:37:52Z blendix $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
Modified: branches/soc-2007-joeedh/source/blender/blenlib/BLI_blenlib.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenlib/BLI_blenlib.h 2007-07-18 10:44:24 UTC (rev 11302)
+++ branches/soc-2007-joeedh/source/blender/blenlib/BLI_blenlib.h 2007-07-18 14:53:17 UTC (rev 11303)
@@ -92,6 +92,24 @@
extern "C" {
#endif
+
+/* Special quick-sort that deals with keeping an array cell's entry in
+ a linked list consistent. This is for if you're sorting an array,
+ whose cells exist in linked lists, and you want to preserve the original
+ lists while sorting.
+
+ NOTE: the linked list header of each element must have an addition ListBase *list reference.
+ e.g.:
+
+ typedef struct element {
+ struct element *next, *prev;
+ ListBase *list;
+ } element;
+
+ . . .and, list MUST be a valid pointer (or NULL);
+ */
+void BLI_qsort_linkedlist_array(void *array1, int len, int elemsize, int (*comparitor)(const void *a1, const void *a2));
+
/* BLI_util.h */
char *BLI_gethome(void);
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
Modified: branches/soc-2007-joeedh/source/blender/blenlib/intern/util.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenlib/intern/util.c 2007-07-18 10:44:24 UTC (rev 11302)
+++ branches/soc-2007-joeedh/source/blender/blenlib/intern/util.c 2007-07-18 14:53:17 UTC (rev 11303)
@@ -1556,3 +1556,73 @@
#endif
+
+ /**/
+
+/* Special quick-sort that deals with keeping an array cell's entry in
+ a linked list consistent. This is for if you're sorting an array,
+ whose cells exist in linked lists, and you want to preserve the original
+ lists while sorting.*/
+
+#define _MEMCPY(a, b, len) {\
+ char *_a = (char*)(a), *_b = (char*)(b); int _len = (len);\
+ for (; _len>0; _len--) *_a = *_b;\
+}
+
+typedef struct LinkExtraHeader {
+ struct LinkExtraHeader *next, *prev;
+ ListBase *list;
+} LinkExtraHeader;
+
+#define ESWAP(a, b, len, scratch) {\
+ LinkExtraHeader *la = (LinkExtraHeader*)(a), *lb = (LinkExtraHeader*)(b);\
+ if (la->prev) la->prev->next = lb;\
+ if (la->next) la->next->prev = lb;\
+ if (lb->prev) lb->prev->next = la;\
+ if (lb->next) lb->next->prev = la;\
+ if (la->list) {\
+ if (la->list->first==la) la->list->first=lb;\
+ if (la->list->last==la) la->list->last=lb;\
+ }\
+ if (lb->list) {\
+ if (lb->list->first==lb) lb->list->first=la;\
+ if (lb->list->last==lb) lb->list->last=la;\
+ }\
+ _MEMCPY(scratch, a, len)\
+ _MEMCPY(a, b, len)\
+ _MEMCPY(b, scratch, len)\
+}
+
+static void bli_qsort_recurse(char *scratch, void *array1, int left, int right, int elemsize, int (*comparitor)(const void *a1, const void *a2))
+{
+ if (right > left) {
+ int pivot = (right+left)/2; //(float)(right+left)*qsort_randtable[(left+right) % QRANDLEN];
+ int i=left, j=right;
+
+ do {
+ while (comparitor(array1+elemsize*i, array1+pivot*elemsize)==-1) i++;
+ while (comparitor(array1+elemsize*j, array1+elemsize*pivot)==1) j--;
+ if (i <= j) {
+ ESWAP(array1+elemsize*i, array1+elemsize*j, elemsize, scratch)
+ i++; j--;
+ }
+ } while (i<=j);
+
+ if (left < j) bli_qsort_recurse(scratch, array1, left, j, elemsize, comparitor);
+ if (i < right) bli_qsort_recurse(scratch, array1, i, right, elemsize, comparitor);
+ }
+}
+
+void BLI_qsort_linkedlist_array(void *array1, int len, int elemsize, int (*comparitor)(const void *a1, const void *a2))
+{
+
+ char stack_mem[8096];
+ char *working_mem;
+
+ if (elemsize > 8096) working_mem = malloc(elemsize);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list