| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * ***** 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.  | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2009 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Blender Foundation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-12 18:24:17 +00:00
										 |  |  | /** \file blender/editors/render/render_update.c
 | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  |  *  \ingroup edrend | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_lamp_types.h"
 | 
					
						
							|  |  |  | #include "DNA_material_types.h"
 | 
					
						
							|  |  |  | #include "DNA_node_types.h"
 | 
					
						
							|  |  |  | #include "DNA_object_types.h"
 | 
					
						
							|  |  |  | #include "DNA_scene_types.h"
 | 
					
						
							|  |  |  | #include "DNA_screen_types.h"
 | 
					
						
							|  |  |  | #include "DNA_space_types.h"
 | 
					
						
							|  |  |  | #include "DNA_view3d_types.h"
 | 
					
						
							|  |  |  | #include "DNA_world_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-28 14:55:35 +00:00
										 |  |  | #include "BLI_threads.h"
 | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BKE_context.h"
 | 
					
						
							|  |  |  | #include "BKE_depsgraph.h"
 | 
					
						
							|  |  |  | #include "BKE_icons.h"
 | 
					
						
							|  |  |  | #include "BKE_image.h"
 | 
					
						
							|  |  |  | #include "BKE_main.h"
 | 
					
						
							|  |  |  | #include "BKE_material.h"
 | 
					
						
							|  |  |  | #include "BKE_node.h"
 | 
					
						
							|  |  |  | #include "BKE_scene.h"
 | 
					
						
							|  |  |  | #include "BKE_texture.h"
 | 
					
						
							|  |  |  | #include "BKE_world.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "GPU_material.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | #include "RE_engine.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-15 12:07:52 +00:00
										 |  |  | #include "ED_node.h"
 | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | #include "ED_render.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | #include "render_intern.h"  // own include
 | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | /***************************** Render Engines ********************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-28 14:55:35 +00:00
										 |  |  | void ED_render_scene_update(Main *bmain, Scene *scene, int updated) | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	/* viewport rendering update on data changes, happens after depsgraph
 | 
					
						
							|  |  |  | 	 * updates if there was any change. context is set to the 3d view */ | 
					
						
							| 
									
										
										
										
											2011-11-28 14:55:35 +00:00
										 |  |  | 	bContext *C; | 
					
						
							|  |  |  | 	bScreen *sc; | 
					
						
							|  |  |  | 	ScrArea *sa; | 
					
						
							|  |  |  | 	ARegion *ar; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* don't do this render engine update if we're updating the scene from
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	 * other threads doing e.g. rendering or baking jobs */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!BLI_thread_is_main()) | 
					
						
							| 
									
										
										
										
											2011-11-28 14:55:35 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	C = CTX_create(); | 
					
						
							| 
									
										
										
										
											2011-11-28 14:55:35 +00:00
										 |  |  | 	CTX_data_main_set(C, bmain); | 
					
						
							|  |  |  | 	CTX_data_scene_set(C, scene); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	CTX_wm_manager_set(C, bmain->wm.first); | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (sc = bmain->screen.first; sc; sc = sc->id.next) { | 
					
						
							|  |  |  | 		for (sa = sc->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (sa->spacetype != SPACE_VIEW3D) | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 				RegionView3D *rv3d; | 
					
						
							|  |  |  | 				RenderEngine *engine; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (ar->regiontype != RGN_TYPE_WINDOW) | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 					continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 				rv3d = ar->regiondata; | 
					
						
							|  |  |  | 				engine = rv3d->render_engine; | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 					CTX_wm_screen_set(C, sc); | 
					
						
							|  |  |  | 					CTX_wm_area_set(C, sa); | 
					
						
							|  |  |  | 					CTX_wm_region_set(C, ar); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					engine->flag &= ~RE_ENGINE_DO_UPDATE; | 
					
						
							|  |  |  | 					engine->type->view_update(engine, C); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-28 14:55:35 +00:00
										 |  |  | 	CTX_free(C); | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ED_render_engine_changed(Main *bmain) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* on changing the render engine type, clear all running render engines */ | 
					
						
							|  |  |  | 	bScreen *sc; | 
					
						
							|  |  |  | 	ScrArea *sa; | 
					
						
							|  |  |  | 	ARegion *ar; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (sc = bmain->screen.first; sc; sc = sc->id.next) { | 
					
						
							|  |  |  | 		for (sa = sc->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (sa->spacetype != SPACE_VIEW3D) | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 				RegionView3D *rv3d; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (ar->regiontype != RGN_TYPE_WINDOW) | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 					continue; | 
					
						
							|  |  |  | 				 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 				rv3d = ar->regiondata; | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (rv3d->render_engine) { | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 					RE_engine_free(rv3d->render_engine); | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 					rv3d->render_engine = NULL; | 
					
						
							| 
									
										
										
										
											2011-11-02 18:20:53 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | /***************************** Updates ***********************************
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | * ED_render_id_flush_update gets called from DAG_id_tag_update, to do * | 
					
						
							|  |  |  | * editor level updates when the ID changes. when these ID blocks are in * | 
					
						
							|  |  |  | * the dependency graph, we can get rid of the manual dependency checks  */ | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int mtex_use_tex(MTex **mtex, int tot, Tex *tex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int a; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!mtex) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (a = 0; a < tot; a++) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (mtex[a] && mtex[a]->tex == tex) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			return 1; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int nodes_use_tex(bNodeTree *ntree, Tex *tex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	bNode *node; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (node = ntree->nodes.first; node; node = node->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (node->id) { | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			if (node->id == (ID *)tex) { | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 				return 1; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			else if (GS(node->id->name) == ID_MA) { | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 				if (mtex_use_tex(((Material *)node->id)->mtex, MAX_MTEX, tex)) | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 					return 1; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			else if (node->type == NODE_GROUP) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (nodes_use_tex((bNodeTree *)node->id, tex)) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 					return 1; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | static int nodes_use_material(bNodeTree *ntree, Material *ma) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	bNode *node; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (node = ntree->nodes.first; node; node = node->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (node->id) { | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			if (node->id == (ID *)ma) { | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 				return 1; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			else if (node->type == NODE_GROUP) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (nodes_use_material((bNodeTree *)node->id, ma)) | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 					return 1; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void material_changed(Main *bmain, Material *ma) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 	Material *parent; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 	/* icons */ | 
					
						
							|  |  |  | 	BKE_icon_changed(BKE_icon_getid(&ma->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* glsl */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (ma->gpumaterial.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 		GPU_material_free(ma); | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* find node materials using this */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (parent = bmain->mat.first; parent; parent = parent->id.next) { | 
					
						
							|  |  |  | 		if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) ; | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 		else continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BKE_icon_changed(BKE_icon_getid(&parent->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (parent->gpumaterial.first) | 
					
						
							| 
									
										
										
										
											2011-11-23 15:16:41 +00:00
										 |  |  | 			GPU_material_free(parent); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void texture_changed(Main *bmain, Tex *tex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Material *ma; | 
					
						
							|  |  |  | 	Lamp *la; | 
					
						
							|  |  |  | 	World *wo; | 
					
						
							| 
									
										
										
										
											2011-08-15 12:07:52 +00:00
										 |  |  | 	Scene *scene; | 
					
						
							|  |  |  | 	bNode *node; | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* icons */ | 
					
						
							|  |  |  | 	BKE_icon_changed(BKE_icon_getid(&tex->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* find materials */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (ma = bmain->mat.first; ma; ma = ma->id.next) { | 
					
						
							|  |  |  | 		if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) ; | 
					
						
							|  |  |  | 		else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) ; | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 		else continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BKE_icon_changed(BKE_icon_getid(&ma->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (ma->gpumaterial.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			GPU_material_free(ma); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* find lamps */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (la = bmain->lamp.first; la; la = la->id.next) { | 
					
						
							|  |  |  | 		if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) ; | 
					
						
							|  |  |  | 		else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) ; | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 		else continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BKE_icon_changed(BKE_icon_getid(&la->id)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* find worlds */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (wo = bmain->world.first; wo; wo = wo->id.next) { | 
					
						
							|  |  |  | 		if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) ; | 
					
						
							|  |  |  | 		else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) ; | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 		else continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BKE_icon_changed(BKE_icon_getid(&wo->id)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-08-15 12:07:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* find compositing nodes */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (scene = bmain->scene.first; scene; scene = scene->id.next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (scene->use_nodes && scene->nodetree) { | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			for (node = scene->nodetree->nodes.first; node; node = node->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (node->id == &tex->id) | 
					
						
							| 
									
										
										
										
											2011-08-15 12:07:52 +00:00
										 |  |  | 					ED_node_changed_update(&scene->id, node); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void lamp_changed(Main *bmain, Lamp *la) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *ob; | 
					
						
							|  |  |  | 	Material *ma; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* icons */ | 
					
						
							|  |  |  | 	BKE_icon_changed(BKE_icon_getid(&la->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* glsl */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (ob = bmain->object.first; ob; ob = ob->id.next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (ob->data == la && ob->gpulamp.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			GPU_lamp_free(ob); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (ma = bmain->mat.first; ma; ma = ma->id.next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (ma->gpumaterial.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			GPU_material_free(ma); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void world_changed(Main *bmain, World *wo) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Material *ma; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* icons */ | 
					
						
							|  |  |  | 	BKE_icon_changed(BKE_icon_getid(&wo->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* glsl */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (ma = bmain->mat.first; ma; ma = ma->id.next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (ma->gpumaterial.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			GPU_material_free(ma); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void image_changed(Main *bmain, Image *ima) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Tex *tex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* icons */ | 
					
						
							|  |  |  | 	BKE_icon_changed(BKE_icon_getid(&ima->id)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* textures */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (tex = bmain->tex.first; tex; tex = tex->id.next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (tex->ima == ima) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			texture_changed(bmain, tex); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void scene_changed(Main *bmain, Scene *UNUSED(scene)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *ob; | 
					
						
							|  |  |  | 	Material *ma; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* glsl */ | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (ob = bmain->object.first; ob; ob = ob->id.next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (ob->gpulamp.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			GPU_lamp_free(ob); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	for (ma = bmain->mat.first; ma; ma = ma->id.next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (ma->gpumaterial.first) | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			GPU_material_free(ma); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ED_render_id_flush_update(Main *bmain, ID *id) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 	switch (GS(id->name)) { | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 		case ID_MA: | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			material_changed(bmain, (Material *)id); | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_TE: | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			texture_changed(bmain, (Tex *)id); | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_WO: | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			world_changed(bmain, (World *)id); | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_LA: | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			lamp_changed(bmain, (Lamp *)id); | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_IM: | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			image_changed(bmain, (Image *)id); | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_SCE: | 
					
						
							| 
									
										
										
										
											2012-03-29 22:42:32 +00:00
										 |  |  | 			scene_changed(bmain, (Scene *)id); | 
					
						
							| 
									
										
										
										
											2011-05-19 11:34:11 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |