use openmp sections for felling origindex arrays

This commit is contained in:
2013-01-18 06:26:06 +00:00
parent 1a131171cb
commit ee0eb394c9
5 changed files with 27 additions and 16 deletions

View File

@@ -95,6 +95,8 @@ struct BMEditMesh;
struct ListBase;
struct PBVH;
#define DM_OMP_LIMIT 0 /* setting zero so we can catch bugs in OpenMP/BMesh */
/* number of sub-elements each mesh element has (for interpolation) */
#define SUB_ELEMS_VERT 0
#define SUB_ELEMS_EDGE 2

View File

@@ -1584,9 +1584,15 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
DM_add_poly_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
range_vn_i(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0);
range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0);
range_vn_i(DM_get_poly_data_layer(dm, CD_ORIGINDEX), dm->numPolyData, 0);
#pragma omp parallel sections if (dm->numVertData + dm->numEdgeData + dm->numPolyData >= DM_OMP_LIMIT)
{
#pragma omp section
{ range_vn_i(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0); }
#pragma omp section
{ range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0); }
#pragma omp section
{ range_vn_i(DM_get_poly_data_layer(dm, CD_ORIGINDEX), dm->numPolyData, 0); }
}
}
}

View File

@@ -37,6 +37,7 @@
#include "BLI_utildefines.h"
#include "BLI_rand.h"
#include "BLI_math_vector.h"
#include "BLI_ghash.h"
#include "DNA_scene_types.h"
@@ -104,12 +105,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
MVert *mvert_src = dm->getVertArray(dm);
vertMap = MEM_callocN(sizeof(*vertMap) * numVert_src, "build modifier vertMap");
for (i = 0; i < numVert_src; i++) vertMap[i] = i;
edgeMap = MEM_callocN(sizeof(*edgeMap) * numEdge_src, "build modifier edgeMap");
for (i = 0; i < numEdge_src; i++) edgeMap[i] = i;
faceMap = MEM_callocN(sizeof(*faceMap) * numPoly_src, "build modifier faceMap");
for (i = 0; i < numPoly_src; i++) faceMap[i] = i;
vertMap = MEM_mallocN(sizeof(*vertMap) * numVert_src, "build modifier vertMap");
edgeMap = MEM_mallocN(sizeof(*edgeMap) * numEdge_src, "build modifier edgeMap");
faceMap = MEM_mallocN(sizeof(*faceMap) * numPoly_src, "build modifier faceMap");
#pragma omp parallel sections if (numVert_src + numEdge_src + numPoly_src >= DM_OMP_LIMIT)
{
#pragma omp section
{ range_vn_i(vertMap, numVert_src, 0); }
#pragma omp section
{ range_vn_i(edgeMap, numEdge_src, 0); }
#pragma omp section
{ range_vn_i(faceMap, numPoly_src, 0); }
}
frac = (BKE_scene_frame_get(md->scene) - bmd->start) / bmd->length;
CLAMP(frac, 0.0f, 1.0f);

View File

@@ -521,11 +521,10 @@ static void fill_laplacian_matrix(LaplacianSystem *sys)
static void validate_solution(LaplacianSystem * sys, short flag, float lambda, float lambda_border)
{
int i, idv1, idv2;
int i;
float lam;
float leni, lene;
float vini, vend;
float *vi1, *vi2, ve1[3], ve2[3];
if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) {
vini = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces);
}

View File

@@ -314,11 +314,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, maxPolys);
}
#if 0 // trunk
origindex = result->getPolyDataArray(result, CD_ORIGINDEX);
#else // bmesh
origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX);
#endif
DM_copy_vert_data(dm, result, 0, 0, totvert); /* copy first otherwise this overwrites our own vertex normals */