diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-09-05 18:33:36 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-09-05 18:33:36 +0400 |
commit | 330aa94ecc0a674c7c2e8c34909c7b8ee9753c31 (patch) | |
tree | 0b4bb82c771d34f85fad19013f3c44f4dad6a1fe /source/blender | |
parent | 5b6e9eec7b907dcd06b81a199c132cac30ed1a6e (diff) |
* GLSL lamps now respect 3d viewport layers.
* Fix undo crash related to sound. Sounds still stop working in
the game engine after undo, but seems to be a different issue.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/GPU_material.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 78 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 6 | ||||
-rw-r--r-- | source/blender/src/editsound.c | 15 |
5 files changed, 71 insertions, 34 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 560421f7edf..ccc687858f4 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -124,7 +124,7 @@ void GPU_material_free(struct Material *ma); void GPU_materials_free(); -void GPU_material_bind(GPUMaterial *material, int lay, double time); +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time); void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]); void GPU_material_unbind(GPUMaterial *material); int GPU_material_bound(GPUMaterial *material); @@ -158,7 +158,7 @@ int GPU_lamp_has_shadow_buffer(GPULamp *lamp); void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize, float winmat[][4]); void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp); -void GPU_lamp_update(GPULamp *lamp, float obmat[][4]); +void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]); int GPU_lamp_shadow_layer(GPULamp *lamp); #ifdef __cplusplus diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 3ff8e7fa559..8922846f365 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -900,7 +900,7 @@ int GPU_enable_material(int nr, void *attribs) gpumat = GPU_material_from_blender(GMS.gscene, mat); GPU_material_vertex_attributes(gpumat, gattribs); - GPU_material_bind(gpumat, GMS.gob->lay, 1.0); + GPU_material_bind(gpumat, GMS.gob->lay, G.vd->lay, 1.0); GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, G.vd->viewmat, G.vd->viewinv, GMS.gob->col); GMS.gboundmat= mat; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 47400f61c25..4e54ca77ec4 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -56,7 +56,6 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" -#include "BLI_linklist.h" #include "GPU_extensions.h" #include "GPU_material.h" @@ -95,7 +94,7 @@ struct GPUMaterial { int obmatloc, invobmatloc; int obcolloc; - LinkNode *lamps; + ListBase lamps; }; struct GPULamp { @@ -132,7 +131,7 @@ struct GPULamp { GPUFrameBuffer *fb; GPUTexture *tex; - LinkNode *materials; + ListBase materials; }; /* Functions */ @@ -221,6 +220,7 @@ static int GPU_material_construct_end(GPUMaterial *material) void GPU_material_free(Material *ma) { LinkData *link; + LinkData *nlink, *mlink, *next; for(link=ma->gpumaterial.first; link; link=link->next) { GPUMaterial *material = link->data; @@ -228,7 +228,17 @@ void GPU_material_free(Material *ma) if(material->pass) GPU_pass_free(material->pass); - BLI_linklist_free(material->lamps, NULL); + for(nlink=material->lamps.first; nlink; nlink=nlink->next) { + GPULamp *lamp = nlink->data; + + for(mlink=lamp->materials.first; mlink; mlink=next) { + next = mlink->next; + if(mlink->data == ma) + BLI_freelinkN(&lamp->materials, mlink); + } + } + + BLI_freelistN(&material->lamps); MEM_freeN(material); } @@ -236,17 +246,17 @@ void GPU_material_free(Material *ma) BLI_freelistN(&ma->gpumaterial); } -void GPU_material_bind(GPUMaterial *material, int lay, double time) +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time) { if(material->pass) { - LinkNode *nlink; + LinkData *nlink; GPULamp *lamp; /* handle layer lamps */ - for(nlink=material->lamps; nlink; nlink=nlink->next) { - lamp= nlink->link; + for(nlink=material->lamps.first; nlink; nlink=nlink->next) { + lamp= nlink->data; - if(!(lamp->mode & LA_LAYER) || (lamp->lay & lay)) { + if((lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) { lamp->dynenergy = lamp->energy; VECCOPY(lamp->dyncol, lamp->col); } @@ -265,7 +275,7 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v { if(material->pass) { GPUShader *shader = GPU_pass_shader(material->pass); - LinkNode *nlink; + LinkData *nlink; GPULamp *lamp; float invmat[4][4], col[4]; @@ -290,8 +300,8 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v } /* update lamps */ - for(nlink=material->lamps; nlink; nlink=nlink->next) { - lamp= nlink->link; + for(nlink=material->lamps.first; nlink; nlink=nlink->next) { + lamp= nlink->data; if(material->dynproperty & DYN_LAMP_VEC) { VECCOPY(lamp->dynvec, lamp->vec); @@ -587,6 +597,13 @@ static void do_specular_ramp(GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *t } } +void add_user_list(ListBase *list, void *data) +{ + LinkData *link = MEM_callocN(sizeof(LinkData), "GPULinkData"); + link->data = data; + BLI_addtail(list, link); +} + static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *lamp) { Material *ma= shi->mat; @@ -668,8 +685,8 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_dynamic_uniform(&lamp->dynenergy), shi->rgb, shi->specrgb, shr->diff, shr->spec, &shr->diff, &shr->spec); - BLI_linklist_append(&mat->lamps, lamp); - BLI_linklist_append(&lamp->materials, ma); + add_user_list(&mat->lamps, lamp); + add_user_list(&lamp->materials, ma); return; } @@ -677,8 +694,8 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } else if((G.fileflags & G_FILE_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { - BLI_linklist_append(&mat->lamps, lamp); - BLI_linklist_append(&lamp->materials, ma); + add_user_list(&mat->lamps, lamp); + add_user_list(&lamp->materials, ma); return; } else @@ -730,8 +747,8 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - BLI_linklist_append(&mat->lamps, lamp); - BLI_linklist_append(&lamp->materials, ma); + add_user_list(&mat->lamps, lamp); + add_user_list(&lamp->materials, ma); } static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) @@ -1258,10 +1275,12 @@ void GPU_materials_free() /* Lamps and shadow buffers */ -void GPU_lamp_update(GPULamp *lamp, float obmat[][4]) +void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]) { float mat[4][4]; + lamp->lay = lay; + Mat4CpyMat4(mat, obmat); Mat4Ortho(mat); @@ -1279,7 +1298,6 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l lamp->ob = ob; lamp->par = par; lamp->la = la; - lamp->lay = ob->lay; /* add_render_lamp */ lamp->mode = la->mode; @@ -1292,7 +1310,7 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l lamp->col[1]= la->g*lamp->energy; lamp->col[2]= la->b*lamp->energy; - GPU_lamp_update(lamp, ob->obmat); + GPU_lamp_update(lamp, ob->lay, ob->obmat); lamp->spotsi= la->spotsize; if(lamp->mode & LA_HALO) @@ -1340,10 +1358,12 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par) GPULamp *lamp; LinkData *link; - for(link=ob->gpulamp.first; link; link=link->next) - if(((GPULamp*)link->data)->par == par && - ((GPULamp*)link->data)->scene == scene) + for(link=ob->gpulamp.first; link; link=link->next) { + lamp = (GPULamp*)link->data; + + if(lamp->par == par && lamp->scene == scene) return link->data; + } lamp = MEM_callocN(sizeof(GPULamp), "GPULamp"); @@ -1383,18 +1403,20 @@ void GPU_lamp_free(Object *ob) { GPULamp *lamp; LinkData *link; - LinkNode *nlink; + LinkData *nlink; Material *ma; for(link=ob->gpulamp.first; link; link=link->next) { lamp = link->data; - for(nlink=lamp->materials; nlink; nlink=nlink->next) { - ma= nlink->link; + while(lamp->materials.first) { + nlink = lamp->materials.first; + ma = nlink->data; + BLI_freelinkN(&lamp->materials, nlink); + if(ma->gpumaterial.first) GPU_material_free(ma); } - BLI_linklist_free(lamp->materials, NULL); gpu_lamp_shadow_free(lamp); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 4658455fe1e..3a054323034 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -2941,9 +2941,9 @@ static void gpu_render_lamp_update(View3D *v3d, Object *ob, Object *par, float o lamp = GPU_lamp_from_blender(G.scene, ob, par); if(lamp) { - GPU_lamp_update(lamp, obmat); - - if(GPU_lamp_has_shadow_buffer(lamp)) { + GPU_lamp_update(lamp, ob->lay, obmat); + + if((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) { shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow"); shadow->lamp = lamp; BLI_addtail(shadows, shadow); diff --git a/source/blender/src/editsound.c b/source/blender/src/editsound.c index 05eb094a7c2..2d70525f971 100644 --- a/source/blender/src/editsound.c +++ b/source/blender/src/editsound.c @@ -275,6 +275,12 @@ void sound_initialize_sounds(void) bSound *sound; if(ghSoundScene) { + for(sound=G.main->sound.first; sound; sound=sound->id.next) { + if(sound->snd_sound) { + SND_RemoveSound(ghSoundScene, sound->snd_sound); + sound->snd_sound = NULL; + } + } /* clear the soundscene */ SND_RemoveAllSounds(ghSoundScene); @@ -908,7 +914,16 @@ void sound_stop_all_sounds(void) void sound_end_all_sounds(void) { #if GAMEBLENDER == 1 + bSound *sound; + if(ghSoundScene) { + for(sound=G.main->sound.first; sound; sound=sound->id.next) { + if(sound->snd_sound) { + SND_RemoveSound(ghSoundScene, sound->snd_sound); + sound->snd_sound = NULL; + } + } + sound_stop_all_sounds(); SND_RemoveAllSounds(ghSoundScene); } |