[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40233] branches/soc-2011-onion-uv-tools/ source/blender/editors: Now corresponding faces belonging to other stitchable uvs are added for preview for vertex case .
Antony Riakiotakis
kalast at gmail.com
Thu Sep 15 16:52:49 CEST 2011
Revision: 40233
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40233
Author: psy-fi
Date: 2011-09-15 14:52:48 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
Now corresponding faces belonging to other stitchable uvs are added for preview for vertex case. Also some comments and indentation corrections
Modified Paths:
--------------
branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c 2011-09-15 14:48:50 UTC (rev 40232)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c 2011-09-15 14:52:48 UTC (rev 40233)
@@ -554,6 +554,8 @@
offset2 = uniqueUv[itmp2];
edges[counter].flag = 0;
+ /* using an order policy, sort uvs according to address space. This avoids
+ * Having two different UvEdges with the same uvs on different positions */
if(offset1 < offset2){
edges[counter].uv1 = offset1;
edges[counter].uv2 = offset2;
Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-09-15 14:48:50 UTC (rev 40232)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-09-15 14:52:48 UTC (rev 40233)
@@ -2175,7 +2175,7 @@
/* Checks for remote uvs that may be stitched with a certain uv, flags them if stitchable. */
-int determine_uv_stitchability(UvElement *element, StitchState *state){
+static int determine_uv_stitchability(UvElement *element, StitchState *state){
int vert_index;
UvElement *element_iter;
float limit= state->limitDist;
@@ -2215,6 +2215,7 @@
IslandStitchData *island_stitch_data = NULL;
short preview_enabled = preview->enabled;
EditFace *efa;
+ EditVert *ev;
/* cleanup previous preview */
stitch_preview_delete();
@@ -2228,55 +2229,70 @@
efa->tmp.l = -1;
}
+ /* Store Indices to editVerts. This is not always needed according to current code so using a flag.
+ * This may be recipe for trouble later though, if something changes. */
+ if(doIndexInit){
+ for(ev = state->em->verts.first, i = 0; ev; ev = ev->next, i++){
+ ev->tmp.l = i;
+ }
+ }
+
+ /* First determine stitchability of uvs */
if(state->mode == VERT_STITCH){
for(i = 0; i < state->selection_size; i++){
if(determine_uv_stitchability(state->selection_stack[i], state)){
- UvElement *element_iter, *element = (UvElement *)state->selection_stack[i];
- element->flag |= STITCH_STITCHABLE;
- for(element_iter = element; element_iter; element_iter = element_iter->next){
- if(element_iter->separate && element_iter != element)
- break;
+ ((UvElement *)(state->selection_stack[i]))->flag |= STITCH_STITCHABLE;
+ }
+ }
+ /* Now we need to register our stitchable and any remote uvs for preview */
+ for(i = 0; i < state->selection_size; i++){
+ UvElement *element = (UvElement *)state->selection_stack[i];
+ if(element->flag & STITCH_STITCHABLE){
+ UvElement *element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
+ for(; element_iter; element_iter = element_iter->next){
stitch_set_face_preview_buffer_position(element_iter->face, preview);
}
}
}
}
- if(!final){
- /* Initialize the preview buffers */
- preview->previewQuads = (float *)MEM_mallocN(preview->numOfQuads*sizeof(float)*8, "quad_uv_stitch_prev");
- preview->previewTris = (float *)MEM_mallocN(preview->numOfTris*sizeof(float)*6, "tri_uv_stitch_prev");
- if(state->mode == VERT_STITCH){
- preview->previewOrig = (float *)MEM_mallocN(preview->numOfOrig*sizeof(float)*2, "stitch_preview_orig_data");
- preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int), "stitch_preview_colors");
- } else {
- preview->previewOrig = (float *)MEM_mallocN(preview->numOfOrig*sizeof(float)*4, "stitch_preview_orig_data");
- preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int)*2, "stitch_preview_colors");
- }
- /* Fill the preview buffers with stitchable only faces */
- for(i = 0; i < state->selection_size; i++){
- UvElement *element = (UvElement *)state->selection_stack[i];
- if(element->flag & STITCH_STITCHABLE){
- UvElement *element_iter = element;
- for(element_iter = element; element_iter; element_iter = element_iter->next){
- if(element_iter->separate && element_iter != element)
- break;
- efa = element_iter->face;
- if(efa->tmp.l != -1)
- {
- MTFace *mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+ if(!final){
+ /* Initialize the preview buffers */
+ preview->previewQuads = (float *)MEM_mallocN(preview->numOfQuads*sizeof(float)*8, "quad_uv_stitch_prev");
+ preview->previewTris = (float *)MEM_mallocN(preview->numOfTris*sizeof(float)*6, "tri_uv_stitch_prev");
+ if(state->mode == VERT_STITCH){
+ preview->previewOrig = (float *)MEM_mallocN(preview->numOfOrig*sizeof(float)*2, "stitch_preview_orig_data");
+ preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int), "stitch_preview_colors");
+ } else {
+ preview->previewOrig = (float *)MEM_mallocN(preview->numOfOrig*sizeof(float)*4, "stitch_preview_orig_data");
+ preview->previewOrigColors = (unsigned int *)MEM_mallocN(preview->numOfOrig*sizeof(unsigned int)*2, "stitch_preview_colors");
+ }
- if(efa->v4) {
- memcpy(preview->previewQuads+efa->tmp.l, &mt->uv[0][0], 8*sizeof(float));
- } else {
- memcpy(preview->previewTris+efa->tmp.l, &mt->uv[0][0], 6*sizeof(float));
- }
+ /* Fill the preview buffers with stitchable only faces */
+ for(i = 0; i < state->selection_size; i++){
+ UvElement *element = (UvElement *)state->selection_stack[i];
+ if(element->flag & STITCH_STITCHABLE){
+ UvElement *element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
+ for(element_iter = element; element_iter; element_iter = element_iter->next){
+ efa = element_iter->face;
+ if(efa->tmp.l != -1)
+ {
+ MTFace *mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+
+ if(efa->v4) {
+ memcpy(preview->previewQuads+efa->tmp.l, &mt->uv[0][0], 8*sizeof(float));
+ } else {
+ memcpy(preview->previewTris+efa->tmp.l, &mt->uv[0][0], 6*sizeof(float));
}
}
}
}
+ else{
+
+ }
}
+ }
return 1;
@@ -2357,20 +2373,23 @@
/* Fill selection stack */
for(efa = stitch_state->em->faces.first ; efa; efa = efa->next){
- int numOfVerts;
- MTFace *mt;
- mt = CustomData_em_get(&stitch_state->em->fdata, efa->data, CD_MTFACE);
- numOfVerts = efa->v4 ? 4 : 3;
+ int numOfVerts;
+ MTFace *mt;
+ mt = CustomData_em_get(&stitch_state->em->fdata, efa->data, CD_MTFACE);
+ numOfVerts = efa->v4 ? 4 : 3;
- for(i = 0; i < numOfVerts; i++){
- if(uvedit_uv_selected(scene, efa, mt, i)){
- int uniqueIndex;
- UvElement *element = get_uv_element(stitch_state->elementMap, efa, i);
- uniqueIndex = stitch_state->map[element - stitch_state->elementMap->buf];
- stitch_state->uvs[uniqueIndex]->flag = STITCH_SELECTED;
+ for(i = 0; i < numOfVerts; i++){
+ if(uvedit_uv_selected(scene, efa, mt, i)){
+ int uniqueIndex;
+ UvElement *element = get_uv_element(stitch_state->elementMap, efa, i);
+ uniqueIndex = stitch_state->map[element - stitch_state->elementMap->buf];
+ /* count a uv only once, or duplicates will happen */
+ if(stitch_state->uvs[uniqueIndex]->flag != STITCH_SELECTED){
stitch_state->selection_stack[stitch_state->selection_size++] = stitch_state->uvs[uniqueIndex];
}
+ stitch_state->uvs[uniqueIndex]->flag = STITCH_SELECTED;
}
+ }
}
stitch_process_data(stitch_state, 0, scene, 1);
More information about the Bf-blender-cvs
mailing list