Пример #1
0
static void shader_preview_free(void *customdata)
{
  ShaderPreview *sp = customdata;
  Main *pr_main = sp->pr_main;

  if (sp->matcopy) {
    sp->id_copy = (ID *)sp->matcopy;
    BLI_remlink(&pr_main->materials, sp->matcopy);
  }
  if (sp->texcopy) {
    sp->id_copy = (ID *)sp->texcopy;
    BLI_remlink(&pr_main->textures, sp->texcopy);
  }
  if (sp->worldcopy) {
    sp->id_copy = (ID *)sp->worldcopy;
    BLI_remlink(&pr_main->worlds, sp->worldcopy);
  }
  if (sp->lampcopy) {
    sp->id_copy = (ID *)sp->lampcopy;
    BLI_remlink(&pr_main->lights, sp->lampcopy);
  }
  if (sp->id_copy) {
    /* node previews */
    shader_preview_updatejob(sp);
  }
  if (sp->id_copy && sp->own_id_copy) {
    struct IDProperty *properties;
    /* get rid of copied ID */
    properties = IDP_GetProperties(sp->id_copy, false);
    if (properties) {
      IDP_FreePropertyContent_ex(properties, false);
      MEM_freeN(properties);
    }
    switch (GS(sp->id_copy->name)) {
      case ID_MA:
        BKE_material_free((Material *)sp->id_copy);
        break;
      case ID_TE:
        BKE_texture_free((Tex *)sp->id_copy);
        break;
      case ID_LA:
        BKE_light_free((Light *)sp->id_copy);
        break;
      case ID_WO:
        BKE_world_free((World *)sp->id_copy);
        break;
      default:
        BLI_assert(!"ID type preview not supported.");
        break;
    }
    MEM_freeN(sp->id_copy);
  }

  MEM_freeN(sp);
}
Пример #2
0
static void shader_preview_free(void *customdata)
{
	ShaderPreview *sp= customdata;
	
	if(sp->matcopy) {
		struct IDProperty *properties;
		int a;
		
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied material */
		BLI_remlink(&pr_main->mat, sp->matcopy);
		
		/* free_material decrements texture, prevent this. hack alert! */
		for(a=0; a<MAX_MTEX; a++) {
			MTex *mtex= sp->matcopy->mtex[a];
			if(mtex && mtex->tex) mtex->tex= NULL;
		}
		
		free_material(sp->matcopy);

		properties= IDP_GetProperties((ID *)sp->matcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->matcopy);
	}
	if(sp->texcopy) {
		struct IDProperty *properties;
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied texture */
		BLI_remlink(&pr_main->tex, sp->texcopy);
		free_texture(sp->texcopy);
		
		properties= IDP_GetProperties((ID *)sp->texcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->texcopy);
	}
	if(sp->worldcopy) {
		struct IDProperty *properties;
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied world */
		BLI_remlink(&pr_main->world, sp->worldcopy);
		free_world(sp->worldcopy);
		
		properties= IDP_GetProperties((ID *)sp->worldcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->worldcopy);
	}
	if(sp->lampcopy) {
		struct IDProperty *properties;
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied lamp */
		BLI_remlink(&pr_main->lamp, sp->lampcopy);
		free_lamp(sp->lampcopy);
		
		properties= IDP_GetProperties((ID *)sp->lampcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->lampcopy);
	}
	
	MEM_freeN(sp);
}
Пример #3
0
IDProperty *rna_ID_idprops(PointerRNA *ptr, bool create)
{
	return IDP_GetProperties(ptr->data, create);
}
Пример #4
0
static void shader_preview_free(void *customdata)
{
	ShaderPreview *sp = customdata;
	Main *pr_main = sp->pr_main;
	
	if (sp->matcopy) {
		struct IDProperty *properties;
		
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied material */
		BLI_remlink(&pr_main->mat, sp->matcopy);
		
		BKE_material_free_ex(sp->matcopy, FALSE);

		properties = IDP_GetProperties((ID *)sp->matcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->matcopy);
	}
	if (sp->texcopy) {
		struct IDProperty *properties;
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied texture */
		BLI_remlink(&pr_main->tex, sp->texcopy);
		BKE_texture_free(sp->texcopy);
		
		properties = IDP_GetProperties((ID *)sp->texcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->texcopy);
	}
	if (sp->worldcopy) {
		struct IDProperty *properties;
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied world */
		BLI_remlink(&pr_main->world, sp->worldcopy);
		BKE_world_free_ex(sp->worldcopy, TRUE); /* [#32865] - we need to unlink the texture copies, unlike for materials */
		
		properties = IDP_GetProperties((ID *)sp->worldcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->worldcopy);
	}
	if (sp->lampcopy) {
		struct IDProperty *properties;
		/* node previews */
		shader_preview_updatejob(sp);
		
		/* get rid of copied lamp */
		BLI_remlink(&pr_main->lamp, sp->lampcopy);
		BKE_lamp_free(sp->lampcopy);
		
		properties = IDP_GetProperties((ID *)sp->lampcopy, FALSE);
		if (properties) {
			IDP_FreeProperty(properties);
			MEM_freeN(properties);
		}
		MEM_freeN(sp->lampcopy);
	}
	
	MEM_freeN(sp);
}