Exemplo n.º 1
0
Tex *copy_texture(Tex *tex)
{
	Tex *texn;
	
	texn= copy_libblock(tex);
	if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima);
	else texn->ima= NULL;
	
	if(texn->plugin) {
		texn->plugin= MEM_dupallocN(texn->plugin);
		open_plugin_tex(texn->plugin);
	}
	
	if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
	if(texn->env) texn->env= BKE_copy_envmap(texn->env);
	if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
	if(texn->vd) texn->vd= MEM_dupallocN(texn->vd);
	if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);

	if(tex->nodetree) {
		if (tex->nodetree->execdata) {
			ntreeTexEndExecTree(tex->nodetree->execdata);
		}
		texn->nodetree= ntreeCopyTree(tex->nodetree); 
	}
	
	return texn;
}
Exemplo n.º 2
0
void TextureBaseOperation::deinitExecution()
{
  this->m_inputSize = NULL;
  this->m_inputOffset = NULL;
  BKE_image_pool_free(this->m_pool);
  this->m_pool = NULL;
  if (this->m_texture != NULL && this->m_texture->use_nodes && this->m_texture->nodetree != NULL &&
      this->m_texture->nodetree->execdata != NULL) {
    ntreeTexEndExecTree(this->m_texture->nodetree->execdata);
  }
  NodeOperation::deinitExecution();
}
Exemplo n.º 3
0
/**
 * Only copy internal data of Texture ID from source to already allocated/initialized destination.
 * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
 *
 * WARNING! This function will not handle ID user count!
 *
 * \param flag  Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
 */
void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const int flag)
{
	/* We never handle usercount here for own data. */
	const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;

	if (!BKE_texture_is_image_user(tex_src)) {
		tex_dst->ima = NULL;
	}

	if (tex_dst->coba) {
		tex_dst->coba = MEM_dupallocN(tex_dst->coba);
	}
	if (tex_dst->env) {
		tex_dst->env = BKE_texture_envmap_copy(tex_dst->env, flag_subdata);
	}
	if (tex_dst->pd) {
		tex_dst->pd = BKE_texture_pointdensity_copy(tex_dst->pd, flag_subdata);
	}
	if (tex_dst->vd) {
		tex_dst->vd = MEM_dupallocN(tex_dst->vd);
	}
	if (tex_dst->ot) {
		tex_dst->ot = BKE_texture_ocean_copy(tex_dst->ot, flag_subdata);
	}

	if (tex_src->nodetree) {
		if (tex_src->nodetree->execdata) {
			ntreeTexEndExecTree(tex_src->nodetree->execdata);
		}
		/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
		 *       (see BKE_libblock_copy_ex()). */
		BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag, false);
	}

	if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
		BKE_previewimg_id_copy(&tex_dst->id, &tex_src->id);
	}
	else {
		tex_dst->preview = NULL;
	}
}
Exemplo n.º 4
0
/* check if texture nodes need exec or end */
static  void ntree_composite_texnode(bNodeTree *ntree, int init)
{
	bNode *node;
	
	for (node= ntree->nodes.first; node; node= node->next) {
		if (node->type==CMP_NODE_TEXTURE && node->id) {
			Tex *tex= (Tex *)node->id;
			if (tex->nodetree && tex->use_nodes) {
				/* has internal flag to detect it only does it once */
				if (init) {
					if (!tex->nodetree->execdata)
						tex->nodetree->execdata = ntreeTexBeginExecTree(tex->nodetree, 1); 
				}
				else
					ntreeTexEndExecTree(tex->nodetree->execdata, 1);
					tex->nodetree->execdata = NULL;
			}
		}
	}

}
Exemplo n.º 5
0
Tex *BKE_texture_copy(Tex *tex)
{
	Tex *texn;
	
	texn = BKE_libblock_copy(&tex->id);
	if (texn->type == TEX_IMAGE) id_us_plus((ID *)texn->ima);
	else texn->ima = NULL;
	
	if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
	if (texn->env) texn->env = BKE_copy_envmap(texn->env);
	if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd);
	if (texn->vd) texn->vd = MEM_dupallocN(texn->vd);
	if (texn->ot) texn->ot = BKE_copy_oceantex(texn->ot);
	if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);

	if (tex->nodetree) {
		if (tex->nodetree->execdata) {
			ntreeTexEndExecTree(tex->nodetree->execdata);
		}
		texn->nodetree = ntreeCopyTree(tex->nodetree);
	}
	
	return texn;
}
Exemplo n.º 6
0
static void group_freeexec(bNode *UNUSED(node), void *nodedata)
{
	bNodeTreeExec*gexec= (bNodeTreeExec*)nodedata;
	
	ntreeTexEndExecTree(gexec, 0);
}