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:
authorCampbell Barton <ideasman42@gmail.com>2007-09-18 23:39:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-09-18 23:39:25 +0400
commit78a20a930a7b3ae251374d433e0a9e8acf15ab65 (patch)
treef4c4095f5aba646181346a13fcda986c88f87a54 /source/blender
parent457824e437e5a7fd2e51886509c58d0f7afb0602 (diff)
fixed copy between UV layers.
made the UV layer menu a generic functions (can make a menu from the names of any custimdata layer type) added a menu in the UV window for selecting teh editnmode UV layer - If there ends up not being enough room in the header this may need to be removed.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_customdata.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h8
-rw-r--r--source/blender/blenkernel/intern/customdata.c23
-rw-r--r--source/blender/src/editmesh_mods.c57
-rw-r--r--source/blender/src/header_image.c40
5 files changed, 113 insertions, 17 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 97491129755..d0535f1752e 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -185,6 +185,8 @@ int CustomData_get_layer_index(const struct CustomData *data, int type);
int CustomData_get_named_layer_index(const struct CustomData *data, int type, char *name);
int CustomData_get_active_layer_index(const struct CustomData *data, int type);
int CustomData_get_render_layer_index(const struct CustomData *data, int type);
+int CustomData_get_active_layer(const struct CustomData *data, int type);
+int CustomData_get_render_layer(const struct CustomData *data, int type);
/* copies the data from source to the data element at index in the first
* layer of type
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 9757d3e6ac1..e9fd059f833 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -110,6 +110,14 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned
UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v);
void free_uv_vert_map(UvVertMap *vmap);
+
+/* functions for making menu's from customdata layers */
+int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to work out how many chars to allocate */
+void mesh_layers_menu_concat(struct CustomData *data, int type, char *str);
+int mesh_layers_menu(struct CustomData *data, int type);
+
+
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 931e555a49e..466ba9f4201 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -545,6 +545,29 @@ int CustomData_get_render_layer_index(const CustomData *data, int type)
return -1;
}
+int CustomData_get_active_layer(const CustomData *data, int type)
+{
+ int i;
+
+ for(i=0; i < data->totlayer; ++i)
+ if(data->layers[i].type == type)
+ return data->layers[i].active;
+
+ return -1;
+}
+
+int CustomData_get_render_layer(const CustomData *data, int type)
+{
+ int i;
+
+ for(i=0; i < data->totlayer; ++i)
+ if(data->layers[i].type == type)
+ return data->layers[i].active_rnd;
+
+ return -1;
+}
+
+
void CustomData_set_layer_active(CustomData *data, int type, int n)
{
int i;
diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c
index 30028fa2453..a0e632e9883 100644
--- a/source/blender/src/editmesh_mods.c
+++ b/source/blender/src/editmesh_mods.c
@@ -1346,23 +1346,48 @@ void select_mesh_group_menu()
}
}
+int mesh_layers_menu_charlen(CustomData *data, int type)
+{
+ int i, len = 0;
+ /* see if there is a duplicate */
+ for(i=0; i<data->totlayer; i++) {
+ if((&data->layers[i])->type == type) {
+ /* we could count the chars here but we'll just assumeme each
+ * is 32 chars with some room for the menu text - 40 should be fine */
+ len+=40;
+ }
+ }
+ return len;
+}
-static short customdata_layers_menu(CustomData *data, int type) {
- int i, ret;
- char *str;
- char *str_pt;
+/* this function adds menu text into an existing string.
+ * this string's size should be allocated with mesh_layers_menu_charlen */
+void mesh_layers_menu_concat(CustomData *data, int type, char *str) {
+ int i, count = 0;
+ char *str_pt = str;
CustomDataLayer *layer;
-
- str = str_pt = MEM_callocN(40 * G.editMesh->fdata.totlayer, "layer menu");
-
/* see if there is a duplicate */
for(i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
if(layer->type == type) {
- str_pt += sprintf(str_pt, "%s%%x%d|", layer->name, i);
+ str_pt += sprintf(str_pt, "%s%%x%d|", layer->name, count);
+ count++;
}
}
+}
+
+int mesh_layers_menu(CustomData *data, int type) {
+ int ret;
+ char *str_pt, *str;
+
+ str_pt = str = MEM_mallocN(mesh_layers_menu_charlen(data, type) + 18, "layer menu");
+ str[0] = '\0';
+
+ str_pt += sprintf(str_pt, "Layers%%t|");
+
+ mesh_layers_menu_concat(data, type, str_pt);
+
ret = pupmenu(str);
MEM_freeN(str);
return ret;
@@ -1585,23 +1610,23 @@ void mesh_copy_menu(void)
} else {
int layer_orig_idx, layer_idx;
- layer_idx = (int)customdata_layers_menu(&em->fdata, CD_MTFACE);
+ layer_idx = mesh_layers_menu(&em->fdata, CD_MTFACE);
if (layer_idx<0) return;
/* warning, have not updated mesh pointers however this is not needed since we swicth back */
- layer_orig_idx = CustomData_get_active_layer_index(&em->fdata, CD_MTFACE);
+ layer_orig_idx = CustomData_get_active_layer(&em->fdata, CD_MTFACE);
if (layer_idx==layer_orig_idx)
return;
/* get the tfaces */
- CustomData_set_layer_active_index(&em->fdata, CD_MTFACE, (int)layer_idx);
+ CustomData_set_layer_active(&em->fdata, CD_MTFACE, (int)layer_idx);
/* store the tfaces in our temp */
for(efa=em->faces.first; efa; efa=efa->next) {
if (efa->f & SELECT) {
efa->tmp.p = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
}
}
- CustomData_set_layer_active_index(&em->fdata, CD_MTFACE, layer_orig_idx);
+ CustomData_set_layer_active(&em->fdata, CD_MTFACE, layer_orig_idx);
}
break;
@@ -1615,23 +1640,23 @@ void mesh_copy_menu(void)
} else {
int layer_orig_idx, layer_idx;
- layer_idx = (int)customdata_layers_menu(&em->fdata, CD_MCOL);
+ layer_idx = mesh_layers_menu(&em->fdata, CD_MCOL);
if (layer_idx<0) return;
/* warning, have not updated mesh pointers however this is not needed since we swicth back */
- layer_orig_idx = CustomData_get_active_layer_index(&em->fdata, CD_MCOL);
+ layer_orig_idx = CustomData_get_active_layer(&em->fdata, CD_MCOL);
if (layer_idx==layer_orig_idx)
return;
/* get the tfaces */
- CustomData_set_layer_active_index(&em->fdata, CD_MCOL, (int)layer_idx);
+ CustomData_set_layer_active(&em->fdata, CD_MCOL, (int)layer_idx);
/* store the tfaces in our temp */
for(efa=em->faces.first; efa; efa=efa->next) {
if (efa->f & SELECT) {
efa->tmp.p = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
}
}
- CustomData_set_layer_active_index(&em->fdata, CD_MCOL, layer_orig_idx);
+ CustomData_set_layer_active(&em->fdata, CD_MCOL, layer_orig_idx);
}
break;
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index cb5bc6579a7..12428e5c431 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -50,6 +50,7 @@
#include "DNA_space_types.h"
#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_customdata_types.h" /* for UV layer menu */
#include "BLI_blenlib.h"
@@ -62,6 +63,8 @@
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_utildefines.h"
+#include "BLI_editVert.h" /* for UV layer menu */
+#include "BKE_customdata.h" /* ditto */
#include "BIF_butspace.h"
#include "BIF_drawimage.h"
@@ -350,6 +353,16 @@ void do_image_buttons(unsigned short event)
}
}
+static void do_image_buttons_set_uvlayer_callback(void *act, void *data)
+{
+ CustomData_set_layer_active(&G.editMesh->fdata, CD_MTFACE, *((int *)act));
+
+ BIF_undo_push("Set Active UV Texture");
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWIMAGE, 0);
+}
+
static void do_image_view_viewnavmenu(void *arg, int event)
{
switch(event) {
@@ -1195,11 +1208,36 @@ void image_buttons(void)
/* UV EditMode buttons, not painting or rencering or compositing */
if ( EM_texFaceCheck() && (G.sima->flag & SI_DRAWTOOL)==0 && !is_render) {
+ int layercount;
xco+=10;
uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, around_pup(), xco,0,XIC+10,YIC, &(G.v2d->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period) ");
xco+= XIC + 12;
uiDefIconButBitI(block, TOG, SI_SYNC_UVSEL, B_REDR, ICON_MESH_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Sync Mesh Selection");
- xco+= XIC+16;
+
+
+ /* Layer Menu */
+ layercount = CustomData_number_of_layers(&G.editMesh->fdata, CD_MTFACE);
+ if (layercount>1 && layercount < 12) { /* could allow any number but limit of 11 means no malloc needed */
+ uiBut *ubut;
+ char str_menu[384], *str_pt; /*384 allows for 11 layers */
+ static int act;
+
+ act = CustomData_get_active_layer(&G.editMesh->fdata, CD_MTFACE);
+
+ /*str_pt = (char *)MEM_mallocN(layercount*40 , "uvmenu"); str[0]='\0';*/
+ str_pt = str_menu;
+ str_pt[0]='\0';
+ mesh_layers_menu_concat(&G.editMesh->fdata, CD_MTFACE, str_pt);
+ xco+= XIC+8;
+ ubut = uiDefButI(block, MENU, B_NOP, str_menu ,xco,0,115,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing");
+ uiButSetFunc(ubut, do_image_buttons_set_uvlayer_callback, &act, NULL);
+
+ /*MEM_freeN(str);*/
+ xco+= 120;
+
+ } else {
+ xco+= XIC+16;
+ }
}
if (ima) {