[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39284] branches/soc-2011-onion/source/ blender: more renames, first part of adjacency data initialization
Antony Riakiotakis
kalast at gmail.com
Thu Aug 11 02:36:55 CEST 2011
Revision: 39284
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39284
Author: psy-fi
Date: 2011-08-11 00:36:54 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
more renames, first part of adjacency data initialization
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/blenkernel/BKE_mesh.h
branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_mesh.h 2011-08-10 23:32:33 UTC (rev 39283)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_mesh.h 2011-08-11 00:36:54 UTC (rev 39284)
@@ -127,17 +127,30 @@
} UvMapVert;
typedef struct UvElementMap {
+ /* address UvElements by their vertex */
struct UvElement **vert;
+ /* UvElement Store */
struct UvElement *buf;
- int numOfUVs;
- int numOfIslands;
+ /* Total number of UVs in the layer. Useful to know */
+ int totalUVs;
+ /* Number of Islands in the mesh */
+ int totalIslands;
+ /* Stores the starting index in buf where each island begins */
int *islandIndices;
} UvElementMap;
typedef struct UvElement {
+ /* Next UvElement corresponding to same vertex */
struct UvElement *next;
+ /* Face the element belongs to */
struct EditFace *face;
- unsigned char tfindex, separate, flag;
+ /* Index in the editFace of the uv */
+ unsigned char tfindex;
+ /* Whether this element is the first of coincident elements */
+ unsigned char separate;
+ /* general use flag */
+ unsigned char flag;
+ /* If generating element map with island sorting, this stores the island index */
unsigned short island;
} UvElement;
Modified: branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c 2011-08-10 23:32:33 UTC (rev 39283)
+++ branches/soc-2011-onion/source/blender/editors/mesh/editmesh_lib.c 2011-08-11 00:36:54 UTC (rev 39284)
@@ -2404,7 +2404,7 @@
return NULL;
}
- vmap->numOfUVs = totuv;
+ vmap->totalUVs = totuv;
for (efa= em->faces.first; efa; a++, efa= efa->next) {
if(!selected || ((!efa->h) && (efa->f & SELECT))) {
@@ -2556,7 +2556,7 @@
MEM_freeN(vmap->buf);
vmap->buf = islandbuf;
- vmap->numOfIslands = nislands;
+ vmap->totalIslands = nislands;
MEM_freeN(stack);
MEM_freeN(map);
}
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c 2011-08-10 23:32:33 UTC (rev 39283)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c 2011-08-11 00:36:54 UTC (rev 39284)
@@ -40,6 +40,7 @@
#include "BLI_utildefines.h"
#include "BLI_editVert.h"
#include "BLI_math.h"
+#include "BLI_ghash.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -70,11 +71,9 @@
#include "UI_view2d.h"
typedef struct UvAdjacencyElement {
- /* pointer to original uv of MTFace */
- float *uv[2];
- /* similar to uvvertmaps, holds the next uv corresponding to the vertex */
- struct UvAdjacencyElement *next;
- /* general use flag */
+ /* pointer to original uvelement */
+ UvElement *element;
+ /* general use flag (Used to check if Element is boundary here) */
char flag;
} UvAdjacencyElement;
@@ -318,14 +317,14 @@
/* custom data for uv smoothing brush */
typedef struct SmoothBrushData{
- /* All uvs of the mesh */
- UvAdjacencyElement *uvs;
-
- /* Contains pointers to the first of each set of coincident uvs.
+ /* Contains the first of each set of coincident uvs.
* These will be used to perform smoothing on and propagate the changes
* to their coincident uvs */
- UvAdjacencyElement **uvCoincidentBases;
+ UvAdjacencyElement *uv;
+ /* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
+ int *uniqueUv;
+
/* Edges used for adjacency info, used with laplacian smoothing */
UvAdjacencyEdge *uvedges;
@@ -396,6 +395,12 @@
{
EM_free_uv_element_map(data->elementMap);
}
+ if(data->uv){
+ MEM_freeN(data->uv);
+ }
+ if(data->uniqueUv){
+ MEM_freeN(data->uniqueUv);
+ }
MEM_freeN(data);
op->customdata = NULL;
}
@@ -411,12 +416,32 @@
op->customdata = data;
if(data){
+ /* This holds a simple information: how many -unique- uvs we have in the uv layer.
+ * Unique Uvs are important because they help us make one UVAdjacencyEdge for a group
+ * of coincident UVs.*/
+ int numOfSeparators = 0, i;
+
data->uvpaint = &ts->uvsmooth->paint;
data->elementMap = EM_make_uv_element_map(em, 0, 0);
if(!data->elementMap){
uv_smooth_stroke_exit(C, op);
return NULL;
}
+
+ /* Count 'unique' uvs */
+ for(i = 0; i < data->elementMap->totalUVs; i++){
+ if(data->elementMap->buf[i].separate){
+ numOfSeparators++;
+ }
+ }
+
+ /* Allocate the unique uv buffers */
+ data->uv = MEM_mallocN(sizeof(*data->uv)*numOfSeparators, "uv_brush_unique_uvs");
+ data->uniqueUv = MEM_mallocN(sizeof(*data->uniqueUv)*data->elementMap->totalUVs, "uv_brush_unique_uv_map");
+ if(!data->uv || !data->uniqueUv){
+ uv_smooth_stroke_exit(C, op);
+ return NULL;
+ }
}
return op->customdata;
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-08-10 23:32:33 UTC (rev 39283)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-08-11 00:36:54 UTC (rev 39284)
@@ -1414,7 +1414,7 @@
MTFace *mt;
UvElement *element;
- for(i = 0; i < state->vmap->numOfIslands; i++){
+ for(i = 0; i < state->vmap->totalIslands; i++){
if(island_stitch_data[i].addedForPreview){
int previewIslandUVs = 0, j;
/* check to avoid divide by 0 */
@@ -1425,8 +1425,8 @@
}
island_stitch_data[i].translation[0] /= island_stitch_data[i].numOfElements;
island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements;
- if(i == state->vmap->numOfIslands-1){
- previewIslandUVs = state->vmap->numOfUVs - state->vmap->islandIndices[i];
+ if(i == state->vmap->totalIslands-1){
+ previewIslandUVs = state->vmap->totalUVs - state->vmap->islandIndices[i];
}else{
previewIslandUVs = state->vmap->islandIndices[i+1] - state->vmap->islandIndices[i];
}
@@ -1540,7 +1540,7 @@
preview->mode = state->mode;
/* UV average is stored for every UV since potentially every UV can be stitched with another. Highly unlikely, I know but possible
* nevertheless :p */
- uv_average = (UVVertAverage *)MEM_callocN(state->vmap->numOfUVs*sizeof(UVVertAverage), "stitch_averages");
+ uv_average = (UVVertAverage *)MEM_callocN(state->vmap->totalUVs*sizeof(UVVertAverage), "stitch_averages");
/* Store Indices to editVerts */
if(doIndexInit){
@@ -1559,7 +1559,7 @@
commonVertMaps = MEM_mallocN(state->em->totface*sizeof(*commonVertMaps), "commonVertMaps");
if(state->snapIslands){
- island_stitch_data = MEM_callocN(sizeof(*island_stitch_data)*state->vmap->numOfIslands, "stitch_island_data");
+ island_stitch_data = MEM_callocN(sizeof(*island_stitch_data)*state->vmap->totalIslands, "stitch_island_data");
}
/* Iterate over all faces and find selected uv's */
@@ -1890,11 +1890,11 @@
MEM_freeN(commonVertMaps);
if(state->snapIslands){
- for(i = 0; i < state->vmap->numOfIslands; i++){
+ for(i = 0; i < state->vmap->totalIslands; i++){
if(island_stitch_data[i].addedForPreview){
int previewIslandUVs = 0, j;
- if(i == state->vmap->numOfIslands-1){
- previewIslandUVs = state->vmap->numOfUVs - state->vmap->islandIndices[i];
+ if(i == state->vmap->totalIslands-1){
+ previewIslandUVs = state->vmap->totalUVs - state->vmap->islandIndices[i];
}else{
previewIslandUVs = state->vmap->islandIndices[i+1] - state->vmap->islandIndices[i];
}
@@ -1932,7 +1932,7 @@
}
}
}
- for(element = vmap->buf, i = 0; i < state->vmap->numOfUVs; element++, i++){
+ for(element = vmap->buf, i = 0; i < state->vmap->totalUVs; element++, i++){
if(preview->mode == VERT_STITCH)
{
if(element->flag & STITCH_STITCHABLE){
@@ -2042,14 +2042,14 @@
{
/* First we need to calculate island rotation because in final calculation we tweak UV's directly, thus altering the results. */
if(state->snapIslands){
- for(element = vmap->buf, i = 0; i < state->vmap->numOfUVs; element++, i++){
+ for(element = vmap->buf, i = 0; i < state->vmap->totalUVs; element++, i++){
if(element->flag & STITCH_EDGE_STITCHABLE){
stitch_island_calculate_rotation(element, i, state, uv_average, island_stitch_data);
}
}
}
- for(element = vmap->buf, i = 0; i < state->vmap->numOfUVs; element++, i++){
+ for(element = vmap->buf, i = 0; i < state->vmap->totalUVs; element++, i++){
if(element->flag & STITCH_STITCHABLE){
float uv[2];
More information about the Bf-blender-cvs
mailing list