misc minor changes
- make cmake osx use of -ftemplate-depth match scons. - use array size within sizeof(), more compact. - replace AT with __func__ where the function is unique enough. - BLI_box_pack_2D -> 2d to match other functions. - rename new mesh normal calculation to mesh.calc_normals_split()
This commit is contained in:
@@ -1784,8 +1784,14 @@ elseif(APPLE)
|
|||||||
set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
|
set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Xcode 5 has too low template depth of 128 for libmv
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
|
if(${CMAKE_GENERATOR} MATCHES "Xcode")
|
||||||
|
if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
|
||||||
|
# Xcode 5 has too low template depth of 128 for libmv
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
@@ -118,8 +118,8 @@ void BKE_mesh_calc_normals_mapping_ex(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pnors) pnors = MEM_callocN(sizeof(float) * 3 * (size_t)numPolys, __func__);
|
if (!pnors) pnors = MEM_callocN(sizeof(float[3]) * (size_t)numPolys, __func__);
|
||||||
/* if (!fnors) fnors = MEM_callocN(sizeof(float) * 3 * numFaces, "face nors mesh.c"); */ /* NO NEED TO ALLOC YET */
|
/* if (!fnors) fnors = MEM_callocN(sizeof(float[3]) * numFaces, "face nors mesh.c"); */ /* NO NEED TO ALLOC YET */
|
||||||
|
|
||||||
|
|
||||||
if (only_face_normals == FALSE) {
|
if (only_face_normals == FALSE) {
|
||||||
@@ -334,7 +334,7 @@ void BKE_mesh_normals_loop_split(MVert *mverts, int UNUSED(numVerts), MEdge *med
|
|||||||
* unset: INDEX_UNSET
|
* unset: INDEX_UNSET
|
||||||
* Note that currently we only have two values for second loop of sharp edges. However, if needed, we can
|
* Note that currently we only have two values for second loop of sharp edges. However, if needed, we can
|
||||||
* store the negated value of loop index instead of INDEX_INVALID to retrieve th real value later in code).
|
* store the negated value of loop index instead of INDEX_INVALID to retrieve th real value later in code).
|
||||||
* Note also that lose edges always have the value 0!
|
* Note also that lose edges always have both values set to 0!
|
||||||
*/
|
*/
|
||||||
int (*edge_to_loops)[2] = MEM_callocN(sizeof(int[2]) * (size_t)numEdges, __func__);
|
int (*edge_to_loops)[2] = MEM_callocN(sizeof(int[2]) * (size_t)numEdges, __func__);
|
||||||
|
|
||||||
@@ -1109,7 +1109,7 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
|
|||||||
const MEdge *medge, int totvert, int totedge)
|
const MEdge *medge, int totvert, int totedge)
|
||||||
{
|
{
|
||||||
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert-edge map");
|
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert-edge map");
|
||||||
int *indices = MEM_mallocN(sizeof(int) * (size_t)totedge * 2, "vert-edge map mem");
|
int *indices = MEM_mallocN(sizeof(int[2]) * (size_t)totedge, "vert-edge map mem");
|
||||||
int *i_pt = indices;
|
int *i_pt = indices;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -1732,6 +1732,7 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
|
|||||||
else {
|
else {
|
||||||
const int side = (int)sqrtf((float)(fd->totdisp / corners));
|
const int side = (int)sqrtf((float)(fd->totdisp / corners));
|
||||||
const int side_sq = side * side;
|
const int side_sq = side * side;
|
||||||
|
const size_t disps_size = sizeof(float[3]) * (size_t)side_sq;
|
||||||
|
|
||||||
for (i = 0; i < tot; i++, disps += side_sq, ld++) {
|
for (i = 0; i < tot; i++, disps += side_sq, ld++) {
|
||||||
ld->totdisp = side_sq;
|
ld->totdisp = side_sq;
|
||||||
@@ -1740,12 +1741,12 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
|
|||||||
if (ld->disps)
|
if (ld->disps)
|
||||||
MEM_freeN(ld->disps);
|
MEM_freeN(ld->disps);
|
||||||
|
|
||||||
ld->disps = MEM_mallocN(sizeof(float) * (size_t)(3 * side_sq), "converted loop mdisps");
|
ld->disps = MEM_mallocN(disps_size, "converted loop mdisps");
|
||||||
if (fd->disps) {
|
if (fd->disps) {
|
||||||
memcpy(ld->disps, disps, sizeof(float) * (size_t)(3 * side_sq));
|
memcpy(ld->disps, disps, disps_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memset(ld->disps, 0, sizeof(float) * (size_t)(3 * side_sq));
|
memset(ld->disps, 0, disps_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ typedef struct BoxPack {
|
|||||||
struct BoxVert *v[4];
|
struct BoxVert *v[4];
|
||||||
} BoxPack;
|
} BoxPack;
|
||||||
|
|
||||||
void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float *tot_height);
|
void BLI_box_pack_2d(BoxPack *boxarray, const int len, float *tot_width, float *tot_height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -156,7 +156,7 @@ static int vertex_sort(const void *p1, const void *p2)
|
|||||||
* len - the number of boxes in the array.
|
* len - the number of boxes in the array.
|
||||||
* tot_width and tot_height are set so you can normalize the data.
|
* tot_width and tot_height are set so you can normalize the data.
|
||||||
* */
|
* */
|
||||||
void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float *tot_height)
|
void BLI_box_pack_2d(BoxPack *boxarray, const int len, float *tot_width, float *tot_height)
|
||||||
{
|
{
|
||||||
BoxVert *vert; /* the current vert */
|
BoxVert *vert; /* the current vert */
|
||||||
int box_index, verts_pack_len, i, j, k, isect;
|
int box_index, verts_pack_len, i, j, k, isect;
|
||||||
|
@@ -444,7 +444,7 @@ static BMVert **hull_input_verts_copy(BMOperator *op,
|
|||||||
static float (*hull_verts_for_bullet(BMVert **input_verts,
|
static float (*hull_verts_for_bullet(BMVert **input_verts,
|
||||||
const int num_input_verts))[3]
|
const int num_input_verts))[3]
|
||||||
{
|
{
|
||||||
float (*coords)[3] = MEM_callocN(sizeof(*coords) * num_input_verts, AT);
|
float (*coords)[3] = MEM_callocN(sizeof(*coords) * num_input_verts, __func__);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_input_verts; i++) {
|
for (i = 0; i < num_input_verts; i++) {
|
||||||
|
@@ -4513,7 +4513,7 @@ void param_pack(ParamHandle *handle, float margin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_box_pack_2D(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
|
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
|
||||||
|
|
||||||
if (tot_height > tot_width)
|
if (tot_height > tot_width)
|
||||||
scale = 1.0f / tot_height;
|
scale = 1.0f / tot_height;
|
||||||
|
@@ -58,7 +58,7 @@ static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, st
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_Mesh_calc_split_normals(Mesh *mesh, float min_angle)
|
static void rna_Mesh_calc_normals_split(Mesh *mesh, float min_angle)
|
||||||
{
|
{
|
||||||
float (*r_loopnors)[3];
|
float (*r_loopnors)[3];
|
||||||
float (*polynors)[3];
|
float (*polynors)[3];
|
||||||
@@ -78,7 +78,7 @@ static void rna_Mesh_calc_split_normals(Mesh *mesh, float min_angle)
|
|||||||
polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
|
polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
polynors = MEM_mallocN(sizeof(float [3]) * mesh->totpoly, AT);
|
polynors = MEM_mallocN(sizeof(float[3]) * mesh->totpoly, __func__);
|
||||||
BKE_mesh_calc_normals_poly(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
BKE_mesh_calc_normals_poly(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||||
polynors, false);
|
polynors, false);
|
||||||
free_polynors = true;
|
free_polynors = true;
|
||||||
@@ -124,7 +124,7 @@ void RNA_api_mesh(StructRNA *srna)
|
|||||||
func = RNA_def_function(srna, "calc_normals", "BKE_mesh_calc_normals");
|
func = RNA_def_function(srna, "calc_normals", "BKE_mesh_calc_normals");
|
||||||
RNA_def_function_ui_description(func, "Calculate vertex normals");
|
RNA_def_function_ui_description(func, "Calculate vertex normals");
|
||||||
|
|
||||||
func = RNA_def_function(srna, "calc_split_normals", "rna_Mesh_calc_split_normals");
|
func = RNA_def_function(srna, "calc_normals_split", "rna_Mesh_calc_normals_split");
|
||||||
RNA_def_function_ui_description(func, "Calculate split vertex normals, which preserve sharp edges");
|
RNA_def_function_ui_description(func, "Calculate split vertex normals, which preserve sharp edges");
|
||||||
parm = RNA_def_float(func, "split_angle", M_PI, 0.0f, M_PI, "",
|
parm = RNA_def_float(func, "split_angle", M_PI, 0.0f, M_PI, "",
|
||||||
"Angle between polys' normals above which an edge is always sharp (180° to disable)",
|
"Angle between polys' normals above which an edge is always sharp (180° to disable)",
|
||||||
|
@@ -1493,7 +1493,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Non Python function */
|
/* Non Python function */
|
||||||
BLI_box_pack_2D(boxarray, len, &tot_width, &tot_height);
|
BLI_box_pack_2d(boxarray, len, &tot_width, &tot_height);
|
||||||
|
|
||||||
boxPack_ToPyObject(boxlist, &boxarray);
|
boxPack_ToPyObject(boxlist, &boxarray);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user