- renderer currently uses links into tface structures that actually

are owned by mesh (or displistmesh)... this causes problems for
   adapting to systems that build tfaces on the fly. Added RE_findTFace
   function to allow allocating tfaces inside renderer itself.
This commit is contained in:
2005-03-28 19:43:45 +00:00
parent f2d940aa1b
commit 983745d102
4 changed files with 43 additions and 1 deletions

View File

@@ -191,6 +191,7 @@ void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi)
struct VlakRen *RE_findOrAddVlak(int nr); struct VlakRen *RE_findOrAddVlak(int nr);
struct VertRen *RE_findOrAddVert(int nr); struct VertRen *RE_findOrAddVert(int nr);
struct HaloRen *RE_findOrAddHalo(int nr); struct HaloRen *RE_findOrAddHalo(int nr);
struct TFace *RE_findTFace(void);
HaloRen *RE_inithalo(struct Material *ma, float *vec, float *vec1, float *orco, float hasize, HaloRen *RE_inithalo(struct Material *ma, float *vec, float *vec1, float *orco, float hasize,
float vectsize, int seed); float vectsize, int seed);

View File

@@ -51,6 +51,17 @@
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
struct TFace;
typedef struct TFaceBlock TFaceBlock;
struct TFaceBlock {
TFaceBlock *next;
struct TFace *tfaces;
int numAvail;
};
/* localized texture result data */ /* localized texture result data */
typedef struct TexResult { typedef struct TexResult {
float tin, tr, tg, tb, ta; float tin, tr, tg, tb, ta;
@@ -139,6 +150,7 @@ typedef struct RE_Render
struct VlakRen **blovl; struct VlakRen **blovl;
struct VertRen **blove; struct VertRen **blove;
struct HaloRen **bloha; struct HaloRen **bloha;
struct TFaceBlock *tfaceBlocks;
int *rectaccu; int *rectaccu;
int *rectz; /* z buffer: distance buffer */ int *rectz; /* z buffer: distance buffer */

View File

@@ -442,6 +442,14 @@ void RE_init_render_data(void)
void RE_free_render_data() void RE_free_render_data()
{ {
TFaceBlock *tfb;
while (tfb = R.tfaceBlocks) {
R.tfaceBlocks = tfb->next;
MEM_freeN(tfb->tfaces);
MEM_freeN(tfb);
}
MEM_freeN(R.blove); MEM_freeN(R.blove);
R.blove= NULL; R.blove= NULL;
MEM_freeN(R.blovl); MEM_freeN(R.blovl);

View File

@@ -65,6 +65,7 @@
#include "BLI_arithb.h" #include "BLI_arithb.h"
#include "DNA_material_types.h" #include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_texture_types.h" #include "DNA_texture_types.h"
#include "BKE_texture.h" #include "BKE_texture.h"
@@ -173,6 +174,26 @@ VlakRen *RE_findOrAddVlak(int nr)
return v; return v;
} }
/* ------------------------------------------------------------------------ */
TFace *RE_findTFace(void)
{
TFaceBlock *tfb = R.tfaceBlocks;
if (!tfb || !tfb->numAvail) {
TFaceBlock *tfbn = MEM_mallocN(sizeof(*tfbn), "TFaceBlock");
tfbn->tfaces = MEM_mallocN(sizeof(*tfbn->tfaces)*TABLEINITSIZE, "TFaceBlock->tfaces");
tfbn->numAvail = TABLEINITSIZE;
tfbn->next = R.tfaceBlocks;
R.tfaceBlocks = tfbn;
tfb = tfbn;
}
return &tfb->tfaces[tfb->numAvail--];
}
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
HaloRen *RE_inithalo(Material *ma, float *vec, float *vec1, HaloRen *RE_inithalo(Material *ma, float *vec, float *vec1,