Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r--source/blender/blenkernel/intern/texture.c102
1 files changed, 86 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 57816b7e470..9075c64d286 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -169,8 +169,8 @@ PluginTex *add_plugin_tex(char *str)
open_plugin_tex(pit);
if(pit->doit==0) {
- if(pit->handle==0); //XXX error("no plugin: %s", str);
- else ; //XXX error("in plugin: %s", str);
+ if(pit->handle==0) {;} //XXX error("no plugin: %s", str);
+ else {;} //XXX error("in plugin: %s", str);
MEM_freeN(pit);
return NULL;
}
@@ -403,6 +403,73 @@ void colorband_table_RGBA(ColorBand *coba, float **array, int *size)
do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]);
}
+int vergcband(const void *a1, const void *a2)
+{
+ const CBData *x1=a1, *x2=a2;
+
+ if( x1->pos > x2->pos ) return 1;
+ else if( x1->pos < x2->pos) return -1;
+ return 0;
+}
+
+CBData *colorband_element_add(struct ColorBand *coba, float position)
+{
+ int a;
+
+ if(coba->tot==MAXCOLORBAND) {
+ return NULL;
+ }
+ else if(coba->tot > 0) {
+ CBData *xnew;
+ float col[4];
+
+ do_colorband(coba, position, col);
+
+ xnew = &coba->data[coba->tot];
+ xnew->pos = position;
+
+ xnew->r = col[0];
+ xnew->g = col[1];
+ xnew->b = col[2];
+ xnew->a = col[3];
+ }
+
+ coba->tot++;
+ coba->cur = coba->tot-1;
+
+ for(a = 0; a < coba->tot; a++)
+ coba->data[a].cur = a;
+
+ qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
+
+ for(a = 0; a < coba->tot; a++) {
+ if(coba->data[a].cur == coba->cur) {
+ coba->cur = a;
+ break;
+ }
+ }
+
+ return coba->data + coba->cur;
+}
+
+int colorband_element_remove(struct ColorBand *coba, int index)
+{
+ int a;
+
+ if(coba->tot < 2)
+ return 0;
+
+ if(index < 0 || index >= coba->tot)
+ return 0;
+
+ for(a = index; a < coba->tot; a++) {
+ coba->data[a] = coba->data[a + 1];
+ }
+ if(coba->cur) coba->cur--;
+ coba->tot--;
+ return 1;
+}
+
/* ******************* TEX ************************ */
void free_texture(Tex *tex)
@@ -535,9 +602,10 @@ void tex_set_type(Tex *tex, int type)
Tex *add_texture(const char *name)
{
+ Main *bmain= G.main;
Tex *tex;
- tex= alloc_libblock(&G.main->tex, ID_TE, name);
+ tex= alloc_libblock(&bmain->tex, ID_TE, name);
default_tex(tex);
@@ -659,6 +727,7 @@ Tex *copy_texture(Tex *tex)
void make_local_texture(Tex *tex)
{
+ Main *bmain= G.main;
Tex *texn;
Material *ma;
World *wrld;
@@ -688,7 +757,7 @@ void make_local_texture(Tex *tex)
return;
}
- ma= G.main->mat.first;
+ ma= bmain->mat.first;
while(ma) {
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
@@ -698,7 +767,7 @@ void make_local_texture(Tex *tex)
}
ma= ma->id.next;
}
- la= G.main->lamp.first;
+ la= bmain->lamp.first;
while(la) {
for(a=0; a<MAX_MTEX; a++) {
if(la->mtex[a] && la->mtex[a]->tex==tex) {
@@ -708,7 +777,7 @@ void make_local_texture(Tex *tex)
}
la= la->id.next;
}
- wrld= G.main->world.first;
+ wrld= bmain->world.first;
while(wrld) {
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
@@ -718,7 +787,7 @@ void make_local_texture(Tex *tex)
}
wrld= wrld->id.next;
}
- br= G.main->brush.first;
+ br= bmain->brush.first;
while(br) {
if(br->mtex.tex==tex) {
if(br->id.lib) lib= 1;
@@ -736,7 +805,7 @@ void make_local_texture(Tex *tex)
texn= copy_texture(tex);
texn->id.us= 0;
- ma= G.main->mat.first;
+ ma= bmain->mat.first;
while(ma) {
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
@@ -749,7 +818,7 @@ void make_local_texture(Tex *tex)
}
ma= ma->id.next;
}
- la= G.main->lamp.first;
+ la= bmain->lamp.first;
while(la) {
for(a=0; a<MAX_MTEX; a++) {
if(la->mtex[a] && la->mtex[a]->tex==tex) {
@@ -762,7 +831,7 @@ void make_local_texture(Tex *tex)
}
la= la->id.next;
}
- wrld= G.main->world.first;
+ wrld= bmain->world.first;
while(wrld) {
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
@@ -775,7 +844,7 @@ void make_local_texture(Tex *tex)
}
wrld= wrld->id.next;
}
- br= G.main->brush.first;
+ br= bmain->brush.first;
while(br) {
if(br->mtex.tex==tex) {
if(br->id.lib==0) {
@@ -793,6 +862,7 @@ void make_local_texture(Tex *tex)
void autotexname(Tex *tex)
{
+ Main *bmain= G.main;
char texstr[20][15]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend",
"Stucci", "Noise" , "Image", "Plugin", "EnvMap" , "Musgrave",
"Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""};
@@ -801,7 +871,7 @@ void autotexname(Tex *tex)
if(tex) {
if(tex->use_nodes) {
- new_id(&G.main->tex, (ID *)tex, "Noddy");
+ new_id(&bmain->tex, (ID *)tex, "Noddy");
}
else
if(tex->type==TEX_IMAGE) {
@@ -811,12 +881,12 @@ void autotexname(Tex *tex)
BLI_splitdirstring(di, fi);
strcpy(di, "I.");
strcat(di, fi);
- new_id(&G.main->tex, (ID *)tex, di);
+ new_id(&bmain->tex, (ID *)tex, di);
}
- else new_id(&G.main->tex, (ID *)tex, texstr[tex->type]);
+ else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
}
- else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&G.main->tex, (ID *)tex, tex->plugin->pname);
- else new_id(&G.main->tex, (ID *)tex, texstr[tex->type]);
+ else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname);
+ else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
}
}