code cleanup: define sizes of vectors for function args and use C style comments
This commit is contained in:
@@ -99,7 +99,7 @@ void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
|
|||||||
/* get_objectspace_bone_matrix has to be removed still */
|
/* get_objectspace_bone_matrix has to be removed still */
|
||||||
void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][4], int root, int posed);
|
void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][4], int root, int posed);
|
||||||
void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]);
|
void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]);
|
||||||
void mat3_to_vec_roll(float mat[][3], float *vec, float *roll);
|
void mat3_to_vec_roll(float mat[][3], float r_vec[3], float *r_roll);
|
||||||
|
|
||||||
/* Common Conversions Between Co-ordinate Spaces */
|
/* Common Conversions Between Co-ordinate Spaces */
|
||||||
void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]);
|
void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void BKE_nurb_free(struct Nurb *nu);
|
|||||||
struct Nurb *BKE_nurb_duplicate(struct Nurb *nu);
|
struct Nurb *BKE_nurb_duplicate(struct Nurb *nu);
|
||||||
|
|
||||||
void BKE_nurb_test2D(struct Nurb *nu);
|
void BKE_nurb_test2D(struct Nurb *nu);
|
||||||
void BKE_nurb_minmax(struct Nurb *nu, float *min, float *max);
|
void BKE_nurb_minmax(struct Nurb *nu, float min[3], float max[3]);
|
||||||
|
|
||||||
void BKE_nurb_makeFaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
|
void BKE_nurb_makeFaces(struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv);
|
||||||
void BKE_nurb_makeCurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
|
void BKE_nurb_makeCurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ struct Lattice *BKE_lattice_add(const char *name);
|
|||||||
struct Lattice *BKE_lattice_copy(struct Lattice *lt);
|
struct Lattice *BKE_lattice_copy(struct Lattice *lt);
|
||||||
void BKE_lattice_free(struct Lattice *lt);
|
void BKE_lattice_free(struct Lattice *lt);
|
||||||
void BKE_lattice_make_local(struct Lattice *lt);
|
void BKE_lattice_make_local(struct Lattice *lt);
|
||||||
void calc_lat_fudu(int flag, int res, float *fu, float *du);
|
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
|
||||||
|
|
||||||
void init_latt_deform(struct Object *oblatt, struct Object *ob);
|
void init_latt_deform(struct Object *oblatt, struct Object *ob);
|
||||||
void calc_latt_deform(struct Object *, float co[3], float weight);
|
void calc_latt_deform(struct Object *, float co[3], float weight);
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ struct Mesh *BKE_mesh_copy(struct Mesh *me);
|
|||||||
void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess_cd);
|
void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess_cd);
|
||||||
|
|
||||||
void BKE_mesh_make_local(struct Mesh *me);
|
void BKE_mesh_make_local(struct Mesh *me);
|
||||||
void BKE_mesh_boundbox_calc(struct Mesh *me, float *loc, float *size);
|
void BKE_mesh_boundbox_calc(struct Mesh *me, float r_loc[3], float r_size[3]);
|
||||||
void BKE_mesh_texspace_calc(struct Mesh *me);
|
void BKE_mesh_texspace_calc(struct Mesh *me);
|
||||||
float *BKE_mesh_orco_verts_get(struct Object *ob);
|
float *BKE_mesh_orco_verts_get(struct Object *ob);
|
||||||
void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert);
|
void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert);
|
||||||
|
|||||||
@@ -1425,19 +1425,20 @@ void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float
|
|||||||
* *************************************************************************** */
|
* *************************************************************************** */
|
||||||
/* Computes vector and roll based on a rotation.
|
/* Computes vector and roll based on a rotation.
|
||||||
* "mat" must contain only a rotation, and no scaling. */
|
* "mat" must contain only a rotation, and no scaling. */
|
||||||
void mat3_to_vec_roll(float mat[][3], float vec[3], float *roll)
|
void mat3_to_vec_roll(float mat[][3], float r_vec[3], float *r_roll)
|
||||||
{
|
{
|
||||||
if (vec)
|
if (r_vec) {
|
||||||
copy_v3_v3(vec, mat[1]);
|
copy_v3_v3(r_vec, mat[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (roll) {
|
if (r_roll) {
|
||||||
float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
|
float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
|
||||||
|
|
||||||
vec_roll_to_mat3(mat[1], 0.0f, vecmat);
|
vec_roll_to_mat3(mat[1], 0.0f, vecmat);
|
||||||
invert_m3_m3(vecmatinv, vecmat);
|
invert_m3_m3(vecmatinv, vecmat);
|
||||||
mul_m3_m3m3(rollmat, vecmatinv, mat);
|
mul_m3_m3m3(rollmat, vecmatinv, mat);
|
||||||
|
|
||||||
*roll = (float)atan2(rollmat[2][0], rollmat[2][2]);
|
*r_roll = atan2f(rollmat[2][0], rollmat[2][2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,19 +64,19 @@
|
|||||||
#include "BKE_deform.h"
|
#include "BKE_deform.h"
|
||||||
|
|
||||||
|
|
||||||
void calc_lat_fudu(int flag, int res, float *fu, float *du)
|
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
|
||||||
{
|
{
|
||||||
if (res == 1) {
|
if (res == 1) {
|
||||||
*fu = 0.0;
|
*r_fu = 0.0;
|
||||||
*du = 0.0;
|
*r_du = 0.0;
|
||||||
}
|
}
|
||||||
else if (flag & LT_GRID) {
|
else if (flag & LT_GRID) {
|
||||||
*fu = -0.5f * (res - 1);
|
*r_fu = -0.5f * (res - 1);
|
||||||
*du = 1.0f;
|
*r_du = 1.0f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*fu = -1.0f;
|
*r_fu = -1.0f;
|
||||||
*du = 2.0f / (res - 1);
|
*r_du = 2.0f / (res - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,36 +44,36 @@
|
|||||||
|
|
||||||
#include "recast-capi.h"
|
#include "recast-capi.h"
|
||||||
|
|
||||||
BLI_INLINE float area2(const float* a, const float* b, const float* c)
|
BLI_INLINE float area2(const float *a, const float *b, const float *c)
|
||||||
{
|
{
|
||||||
return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);
|
return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_INLINE int left(const float* a, const float* b, const float* c)
|
BLI_INLINE int left(const float *a, const float *b, const float *c)
|
||||||
{
|
{
|
||||||
return area2(a, b, c) < 0;
|
return area2(a, b, c) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int polyNumVerts(const unsigned short* p, const int vertsPerPoly)
|
int polyNumVerts(const unsigned short *p, const int vertsPerPoly)
|
||||||
{
|
{
|
||||||
int i, nv = 0;
|
int i, nv = 0;
|
||||||
for (i=0; i<vertsPerPoly; i++) {
|
for (i = 0; i < vertsPerPoly; i++) {
|
||||||
if (p[i]==0xffff)
|
if (p[i] == 0xffff)
|
||||||
break;
|
break;
|
||||||
nv++;
|
nv++;
|
||||||
}
|
}
|
||||||
return nv;
|
return nv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* verts)
|
int polyIsConvex(const unsigned short *p, const int vertsPerPoly, const float *verts)
|
||||||
{
|
{
|
||||||
int j, nv = polyNumVerts(p, vertsPerPoly);
|
int j, nv = polyNumVerts(p, vertsPerPoly);
|
||||||
if (nv<3)
|
if (nv < 3)
|
||||||
return 0;
|
return 0;
|
||||||
for (j=0; j<nv; j++) {
|
for (j = 0; j < nv; j++) {
|
||||||
const float* v = &verts[3*p[j]];
|
const float *v = &verts[3 * p[j]];
|
||||||
const float* v_next = &verts[3*p[(j+1)%nv]];
|
const float *v_next = &verts[3 * p[(j + 1) % nv]];
|
||||||
const float* v_prev = &verts[3*p[(nv+j-1)%nv]];
|
const float *v_prev = &verts[3 * p[(nv + j - 1) % nv]];
|
||||||
if (!left(v_prev, v, v_next))
|
if (!left(v_prev, v, v_next))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -81,7 +81,8 @@ int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* v
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
float distPointToSegmentSq(const float* point, const float* a, const float* b)
|
/* XXX, could replace with #dist_to_line_segment_v3(), or add a squared version */
|
||||||
|
float distPointToSegmentSq(const float point[3], const float a[3], const float b[3])
|
||||||
{
|
{
|
||||||
float abx[3], dx[3];
|
float abx[3], dx[3];
|
||||||
float d, t;
|
float d, t;
|
||||||
@@ -89,24 +90,24 @@ float distPointToSegmentSq(const float* point, const float* a, const float* b)
|
|||||||
sub_v3_v3v3(abx, b, a);
|
sub_v3_v3v3(abx, b, a);
|
||||||
sub_v3_v3v3(dx, point, a);
|
sub_v3_v3v3(dx, point, a);
|
||||||
|
|
||||||
d = abx[0]*abx[0]+abx[2]*abx[2];
|
d = abx[0] * abx[0] + abx[2] * abx[2];
|
||||||
t = abx[0]*dx[0]+abx[2]*dx[2];
|
t = abx[0] * dx[0] + abx[2] * dx[2];
|
||||||
|
|
||||||
if (d > 0)
|
if (d > 0.0f)
|
||||||
t /= d;
|
t /= d;
|
||||||
if (t < 0)
|
if (t < 0.0f)
|
||||||
t = 0;
|
t = 0.0f;
|
||||||
else if (t > 1)
|
else if (t > 1.0f)
|
||||||
t = 1;
|
t = 1.0f;
|
||||||
dx[0] = a[0] + t*abx[0] - point[0];
|
dx[0] = a[0] + t * abx[0] - point[0];
|
||||||
dx[2] = a[2] + t*abx[2] - point[2];
|
dx[2] = a[2] + t * abx[2] - point[2];
|
||||||
|
|
||||||
return dx[0]*dx[0] + dx[2]*dx[2];
|
return dx[0] * dx[0] + dx[2] * dx[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
int buildRawVertIndicesData(DerivedMesh *dm, int *nverts_r, float **verts_r,
|
||||||
int *ntris_r, unsigned short **tris_r, int **trisToFacesMap_r,
|
int *ntris_r, unsigned short **tris_r, int **trisToFacesMap_r,
|
||||||
int **recastData)
|
int **recastData)
|
||||||
{
|
{
|
||||||
int vi, fi, triIdx;
|
int vi, fi, triIdx;
|
||||||
int nverts, ntris;
|
int nverts, ntris;
|
||||||
@@ -117,49 +118,49 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
|||||||
MFace *faces;
|
MFace *faces;
|
||||||
|
|
||||||
nverts = dm->getNumVerts(dm);
|
nverts = dm->getNumVerts(dm);
|
||||||
if (nverts>=0xffff) {
|
if (nverts >= 0xffff) {
|
||||||
printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
|
printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
verts = MEM_callocN(sizeof(float)*3*nverts, "buildRawVertIndicesData verts");
|
verts = MEM_callocN(sizeof(float) * 3 * nverts, "buildRawVertIndicesData verts");
|
||||||
dm->getVertCos(dm, (float(*)[3])verts);
|
dm->getVertCos(dm, (float(*)[3])verts);
|
||||||
|
|
||||||
//flip coordinates
|
/* flip coordinates */
|
||||||
for (vi=0; vi<nverts; vi++) {
|
for (vi = 0; vi < nverts; vi++) {
|
||||||
SWAP(float, verts[3*vi+1], verts[3*vi+2]);
|
SWAP(float, verts[3 * vi + 1], verts[3 * vi + 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate number of tris
|
/* calculate number of tris */
|
||||||
nfaces = dm->getNumTessFaces(dm);
|
nfaces = dm->getNumTessFaces(dm);
|
||||||
faces = dm->getTessFaceArray(dm);
|
faces = dm->getTessFaceArray(dm);
|
||||||
ntris = nfaces;
|
ntris = nfaces;
|
||||||
for (fi=0; fi<nfaces; fi++) {
|
for (fi = 0; fi < nfaces; fi++) {
|
||||||
MFace* face = &faces[fi];
|
MFace *face = &faces[fi];
|
||||||
if (face->v4)
|
if (face->v4)
|
||||||
ntris++;
|
ntris++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//copy and transform to triangles (reorder on the run)
|
/* copy and transform to triangles (reorder on the run) */
|
||||||
trisToFacesMap = MEM_callocN(sizeof(int)*ntris, "buildRawVertIndicesData trisToFacesMap");
|
trisToFacesMap = MEM_callocN(sizeof(int) * ntris, "buildRawVertIndicesData trisToFacesMap");
|
||||||
tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris");
|
tris = MEM_callocN(sizeof(unsigned short) * 3 * ntris, "buildRawVertIndicesData tris");
|
||||||
tri = tris;
|
tri = tris;
|
||||||
triIdx = 0;
|
triIdx = 0;
|
||||||
for (fi=0; fi<nfaces; fi++) {
|
for (fi = 0; fi < nfaces; fi++) {
|
||||||
MFace* face = &faces[fi];
|
MFace *face = &faces[fi];
|
||||||
tri[3*triIdx+0] = (unsigned short) face->v1;
|
tri[3 * triIdx + 0] = (unsigned short) face->v1;
|
||||||
tri[3*triIdx+1] = (unsigned short) face->v3;
|
tri[3 * triIdx + 1] = (unsigned short) face->v3;
|
||||||
tri[3*triIdx+2] = (unsigned short) face->v2;
|
tri[3 * triIdx + 2] = (unsigned short) face->v2;
|
||||||
trisToFacesMap[triIdx++]=fi;
|
trisToFacesMap[triIdx++] = fi;
|
||||||
if (face->v4) {
|
if (face->v4) {
|
||||||
tri[3*triIdx+0] = (unsigned short) face->v1;
|
tri[3 * triIdx + 0] = (unsigned short) face->v1;
|
||||||
tri[3*triIdx+1] = (unsigned short) face->v4;
|
tri[3 * triIdx + 1] = (unsigned short) face->v4;
|
||||||
tri[3*triIdx+2] = (unsigned short) face->v3;
|
tri[3 * triIdx + 2] = (unsigned short) face->v3;
|
||||||
trisToFacesMap[triIdx++]=fi;
|
trisToFacesMap[triIdx++] = fi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//carefully, recast data is just reference to data in derived mesh
|
/* carefully, recast data is just reference to data in derived mesh */
|
||||||
*recastData = (int*)CustomData_get_layer(&dm->polyData, CD_RECAST);
|
*recastData = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST);
|
||||||
|
|
||||||
*nverts_r = nverts;
|
*nverts_r = nverts;
|
||||||
*verts_r = verts;
|
*verts_r = verts;
|
||||||
@@ -170,122 +171,122 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
|
||||||
unsigned short* polys, const unsigned short* dmeshes,
|
unsigned short *polys, const unsigned short *dmeshes,
|
||||||
const float* verts, const unsigned short* dtris,
|
const float *verts, const unsigned short *dtris,
|
||||||
const int* dtrisToPolysMap)
|
const int *dtrisToPolysMap)
|
||||||
{
|
{
|
||||||
int polyidx;
|
int polyidx;
|
||||||
int capacity = vertsPerPoly;
|
int capacity = vertsPerPoly;
|
||||||
unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly");
|
unsigned short *newPoly = MEM_callocN(sizeof(unsigned short) * capacity, "buildPolygonsByDetailedMeshes newPoly");
|
||||||
memset(newPoly, 0xff, sizeof(unsigned short)*capacity);
|
memset(newPoly, 0xff, sizeof(unsigned short) * capacity);
|
||||||
|
|
||||||
for (polyidx=0; polyidx<npolys; polyidx++) {
|
for (polyidx = 0; polyidx < npolys; polyidx++) {
|
||||||
size_t i;
|
size_t i;
|
||||||
int j, k;
|
int j, k;
|
||||||
int nv = 0;
|
int nv = 0;
|
||||||
//search border
|
/* search border */
|
||||||
int tri, btri = -1;
|
int tri, btri = -1;
|
||||||
int edge, bedge = -1;
|
int edge, bedge = -1;
|
||||||
int dtrisNum = dmeshes[polyidx*4+3];
|
int dtrisNum = dmeshes[polyidx * 4 + 3];
|
||||||
int dtrisBase = dmeshes[polyidx*4+2];
|
int dtrisBase = dmeshes[polyidx * 4 + 2];
|
||||||
unsigned char *traversedTris = MEM_callocN(sizeof(unsigned char)*dtrisNum, "buildPolygonsByDetailedMeshes traversedTris");
|
unsigned char *traversedTris = MEM_callocN(sizeof(unsigned char) * dtrisNum, "buildPolygonsByDetailedMeshes traversedTris");
|
||||||
unsigned short* adjustedPoly;
|
unsigned short *adjustedPoly;
|
||||||
int adjustedNv;
|
int adjustedNv;
|
||||||
int allBorderTraversed;
|
int allBorderTraversed;
|
||||||
|
|
||||||
for (j=0; j<dtrisNum && btri==-1;j++) {
|
for (j = 0; j < dtrisNum && btri == -1; j++) {
|
||||||
int curpolytri = dtrisBase+j;
|
int curpolytri = dtrisBase + j;
|
||||||
for (k=0; k<3; k++) {
|
for (k = 0; k < 3; k++) {
|
||||||
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
|
unsigned short neighbortri = dtris[curpolytri * 3 * 2 + 3 + k];
|
||||||
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
|
if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
|
||||||
btri = curpolytri;
|
btri = curpolytri;
|
||||||
bedge = k;
|
bedge = k;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (btri==-1 || bedge==-1) {
|
if (btri == -1 || bedge == -1) {
|
||||||
//can't find triangle with border edge
|
/* can't find triangle with border edge */
|
||||||
MEM_freeN(traversedTris);
|
MEM_freeN(traversedTris);
|
||||||
MEM_freeN(newPoly);
|
MEM_freeN(newPoly);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
newPoly[nv++] = dtris[btri*3*2+bedge];
|
newPoly[nv++] = dtris[btri * 3 * 2 + bedge];
|
||||||
tri = btri;
|
tri = btri;
|
||||||
edge = (bedge+1)%3;
|
edge = (bedge + 1) % 3;
|
||||||
traversedTris[tri-dtrisBase] = 1;
|
traversedTris[tri - dtrisBase] = 1;
|
||||||
while (tri != btri || edge != bedge) {
|
while (tri != btri || edge != bedge) {
|
||||||
int neighbortri = dtris[tri*3*2+3+edge];
|
int neighbortri = dtris[tri * 3 * 2 + 3 + edge];
|
||||||
if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
|
if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
|
||||||
if (nv==capacity) {
|
if (nv == capacity) {
|
||||||
unsigned short* newPolyBig;
|
unsigned short *newPolyBig;
|
||||||
capacity += vertsPerPoly;
|
capacity += vertsPerPoly;
|
||||||
newPolyBig = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPolyBig");
|
newPolyBig = MEM_callocN(sizeof(unsigned short) * capacity, "buildPolygonsByDetailedMeshes newPolyBig");
|
||||||
memset(newPolyBig, 0xff, sizeof(unsigned short)*capacity);
|
memset(newPolyBig, 0xff, sizeof(unsigned short) * capacity);
|
||||||
memcpy(newPolyBig, newPoly, sizeof(unsigned short)*nv);
|
memcpy(newPolyBig, newPoly, sizeof(unsigned short) * nv);
|
||||||
MEM_freeN(newPoly);
|
MEM_freeN(newPoly);
|
||||||
newPoly = newPolyBig;
|
newPoly = newPolyBig;
|
||||||
}
|
}
|
||||||
newPoly[nv++] = dtris[tri*3*2+edge];
|
newPoly[nv++] = dtris[tri * 3 * 2 + edge];
|
||||||
//move to next edge
|
/* move to next edge */
|
||||||
edge = (edge+1)%3;
|
edge = (edge + 1) % 3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//move to next tri
|
/* move to next tri */
|
||||||
int twinedge = -1;
|
int twinedge = -1;
|
||||||
for (k=0; k<3; k++) {
|
for (k = 0; k < 3; k++) {
|
||||||
if (dtris[neighbortri*3*2+3+k] == tri) {
|
if (dtris[neighbortri * 3 * 2 + 3 + k] == tri) {
|
||||||
twinedge = k;
|
twinedge = k;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (twinedge==-1) {
|
if (twinedge == -1) {
|
||||||
printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
|
printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
|
||||||
MEM_freeN(traversedTris);
|
MEM_freeN(traversedTris);
|
||||||
goto returnLabel;
|
goto returnLabel;
|
||||||
}
|
}
|
||||||
tri = neighbortri;
|
tri = neighbortri;
|
||||||
edge = (twinedge+1)%3;
|
edge = (twinedge + 1) % 3;
|
||||||
traversedTris[tri-dtrisBase] = 1;
|
traversedTris[tri - dtrisBase] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustedPoly = MEM_callocN(sizeof(unsigned short)*nv, "buildPolygonsByDetailedMeshes adjustedPoly");
|
adjustedPoly = MEM_callocN(sizeof(unsigned short) * nv, "buildPolygonsByDetailedMeshes adjustedPoly");
|
||||||
adjustedNv = 0;
|
adjustedNv = 0;
|
||||||
for (i=0; i<nv; i++) {
|
for (i = 0; i < nv; i++) {
|
||||||
unsigned short prev = newPoly[(nv+i-1)%nv];
|
unsigned short prev = newPoly[(nv + i - 1) % nv];
|
||||||
unsigned short cur = newPoly[i];
|
unsigned short cur = newPoly[i];
|
||||||
unsigned short next = newPoly[(i+1)%nv];
|
unsigned short next = newPoly[(i + 1) % nv];
|
||||||
float distSq = distPointToSegmentSq(&verts[3*cur], &verts[3*prev], &verts[3*next]);
|
float distSq = distPointToSegmentSq(&verts[3 * cur], &verts[3 * prev], &verts[3 * next]);
|
||||||
static const float tolerance = 0.001f;
|
static const float tolerance = 0.001f;
|
||||||
if (distSq>tolerance)
|
if (distSq > tolerance)
|
||||||
adjustedPoly[adjustedNv++] = cur;
|
adjustedPoly[adjustedNv++] = cur;
|
||||||
}
|
}
|
||||||
memcpy(newPoly, adjustedPoly, adjustedNv*sizeof(unsigned short));
|
memcpy(newPoly, adjustedPoly, adjustedNv * sizeof(unsigned short));
|
||||||
MEM_freeN(adjustedPoly);
|
MEM_freeN(adjustedPoly);
|
||||||
nv = adjustedNv;
|
nv = adjustedNv;
|
||||||
|
|
||||||
allBorderTraversed = 1;
|
allBorderTraversed = 1;
|
||||||
for (i=0; i<dtrisNum; i++) {
|
for (i = 0; i < dtrisNum; i++) {
|
||||||
if (traversedTris[i]==0) {
|
if (traversedTris[i] == 0) {
|
||||||
//check whether it has border edges
|
/* check whether it has border edges */
|
||||||
int curpolytri = dtrisBase+i;
|
int curpolytri = dtrisBase + i;
|
||||||
for (k=0; k<3; k++) {
|
for (k = 0; k < 3; k++) {
|
||||||
unsigned short neighbortri = dtris[curpolytri*3*2+3+k];
|
unsigned short neighbortri = dtris[curpolytri * 3 * 2 + 3 + k];
|
||||||
if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) {
|
if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
|
||||||
allBorderTraversed = 0;
|
allBorderTraversed = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nv<=vertsPerPoly && allBorderTraversed) {
|
if (nv <= vertsPerPoly && allBorderTraversed) {
|
||||||
for (i=0; i<nv; i++) {
|
for (i = 0; i < nv; i++) {
|
||||||
polys[polyidx*vertsPerPoly*2+i] = newPoly[i];
|
polys[polyidx * vertsPerPoly * 2 + i] = newPoly[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,21 +299,20 @@ returnLabel:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SortContext
|
struct SortContext {
|
||||||
{
|
const int *recastData;
|
||||||
const int* recastData;
|
const int *trisToFacesMap;
|
||||||
const int* trisToFacesMap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int compareByData(void *ctx, const void * a, const void * b)
|
static int compareByData(void *ctx, const void *a, const void *b)
|
||||||
{
|
{
|
||||||
return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int*)a]] -
|
return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)a]] -
|
||||||
((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int*)b]] );
|
((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)b]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int buildNavMeshData(const int nverts, const float* verts,
|
int buildNavMeshData(const int nverts, const float *verts,
|
||||||
const int ntris, const unsigned short *tris,
|
const int ntris, const unsigned short *tris,
|
||||||
const int* recastData, const int* trisToFacesMap,
|
const int *recastData, const int *trisToFacesMap,
|
||||||
int *ndtris_r, unsigned short **dtris_r,
|
int *ndtris_r, unsigned short **dtris_r,
|
||||||
int *npolys_r, unsigned short **dmeshes_r, unsigned short **polys_r,
|
int *npolys_r, unsigned short **dmeshes_r, unsigned short **polys_r,
|
||||||
int *vertsPerPoly_r, int **dtrisToPolysMap_r, int **dtrisToTrisMap_r)
|
int *vertsPerPoly_r, int **dtrisToPolysMap_r, int **dtrisToTrisMap_r)
|
||||||
@@ -333,86 +333,86 @@ int buildNavMeshData(const int nverts, const float* verts,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
trisMapping = MEM_callocN(sizeof(int)*ntris, "buildNavMeshData trisMapping");
|
trisMapping = MEM_callocN(sizeof(int) * ntris, "buildNavMeshData trisMapping");
|
||||||
|
|
||||||
//sort the triangles by polygon idx
|
/* sort the triangles by polygon idx */
|
||||||
for (i=0; i<ntris; i++)
|
for (i = 0; i < ntris; i++)
|
||||||
trisMapping[i]=i;
|
trisMapping[i] = i;
|
||||||
context.recastData = recastData;
|
context.recastData = recastData;
|
||||||
context.trisToFacesMap = trisToFacesMap;
|
context.trisToFacesMap = trisToFacesMap;
|
||||||
recast_qsort(trisMapping, ntris, sizeof(int), &context, compareByData);
|
recast_qsort(trisMapping, ntris, sizeof(int), &context, compareByData);
|
||||||
|
|
||||||
//search first valid triangle - triangle of convex polygon
|
/* search first valid triangle - triangle of convex polygon */
|
||||||
validTriStart = -1;
|
validTriStart = -1;
|
||||||
for (i=0; i< ntris; i++) {
|
for (i = 0; i < ntris; i++) {
|
||||||
if (recastData[trisToFacesMap[trisMapping[i]]]>0) {
|
if (recastData[trisToFacesMap[trisMapping[i]]] > 0) {
|
||||||
validTriStart = i;
|
validTriStart = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validTriStart<0) {
|
if (validTriStart < 0) {
|
||||||
printf("Converting navmesh: Error! No valid polygons in mesh\n");
|
printf("Converting navmesh: Error! No valid polygons in mesh\n");
|
||||||
MEM_freeN(trisMapping);
|
MEM_freeN(trisMapping);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ndtris = ntris-validTriStart;
|
ndtris = ntris - validTriStart;
|
||||||
//fill dtris to faces mapping
|
/* fill dtris to faces mapping */
|
||||||
dtrisToTrisMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToTrisMap");
|
dtrisToTrisMap = MEM_callocN(sizeof(int) * ndtris, "buildNavMeshData dtrisToTrisMap");
|
||||||
memcpy(dtrisToTrisMap, &trisMapping[validTriStart], ndtris*sizeof(int));
|
memcpy(dtrisToTrisMap, &trisMapping[validTriStart], ndtris * sizeof(int));
|
||||||
MEM_freeN(trisMapping);
|
MEM_freeN(trisMapping);
|
||||||
|
|
||||||
//create detailed mesh triangles - copy only valid triangles
|
/* create detailed mesh triangles - copy only valid triangles
|
||||||
//and reserve memory for adjacency info
|
* and reserve memory for adjacency info */
|
||||||
dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris");
|
dtris = MEM_callocN(sizeof(unsigned short) * 3 * 2 * ndtris, "buildNavMeshData dtris");
|
||||||
memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris);
|
memset(dtris, 0xffff, sizeof(unsigned short) * 3 * 2 * ndtris);
|
||||||
for (i=0; i<ndtris; i++) {
|
for (i = 0; i < ndtris; i++) {
|
||||||
memcpy(dtris+3*2*i, tris+3*dtrisToTrisMap[i], sizeof(unsigned short)*3);
|
memcpy(dtris + 3 * 2 * i, tris + 3 * dtrisToTrisMap[i], sizeof(unsigned short) * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
//create new recast data corresponded to dtris and renumber for continuous indices
|
/* create new recast data corresponded to dtris and renumber for continuous indices */
|
||||||
prevPolyIdx = -1;
|
prevPolyIdx = -1;
|
||||||
newPolyIdx = 0;
|
newPolyIdx = 0;
|
||||||
dtrisToPolysMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToPolysMap");
|
dtrisToPolysMap = MEM_callocN(sizeof(int) * ndtris, "buildNavMeshData dtrisToPolysMap");
|
||||||
for (i=0; i<ndtris; i++) {
|
for (i = 0; i < ndtris; i++) {
|
||||||
curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
|
curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
|
||||||
if (curPolyIdx!=prevPolyIdx) {
|
if (curPolyIdx != prevPolyIdx) {
|
||||||
newPolyIdx++;
|
newPolyIdx++;
|
||||||
prevPolyIdx=curPolyIdx;
|
prevPolyIdx = curPolyIdx;
|
||||||
}
|
}
|
||||||
dtrisToPolysMap[i] = newPolyIdx;
|
dtrisToPolysMap[i] = newPolyIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//build adjacency info for detailed mesh triangles
|
/* build adjacency info for detailed mesh triangles */
|
||||||
recast_buildMeshAdjacency(dtris, ndtris, nverts, 3);
|
recast_buildMeshAdjacency(dtris, ndtris, nverts, 3);
|
||||||
|
|
||||||
//create detailed mesh description for each navigation polygon
|
/* create detailed mesh description for each navigation polygon */
|
||||||
npolys = dtrisToPolysMap[ndtris-1];
|
npolys = dtrisToPolysMap[ndtris - 1];
|
||||||
dmeshes = MEM_callocN(sizeof(unsigned short)*npolys*4, "buildNavMeshData dmeshes");
|
dmeshes = MEM_callocN(sizeof(unsigned short) * npolys * 4, "buildNavMeshData dmeshes");
|
||||||
memset(dmeshes, 0, npolys*4*sizeof(unsigned short));
|
memset(dmeshes, 0, npolys * 4 * sizeof(unsigned short));
|
||||||
dmesh = NULL;
|
dmesh = NULL;
|
||||||
prevpolyidx = 0;
|
prevpolyidx = 0;
|
||||||
for (i=0; i<ndtris; i++) {
|
for (i = 0; i < ndtris; i++) {
|
||||||
int curpolyidx = dtrisToPolysMap[i];
|
int curpolyidx = dtrisToPolysMap[i];
|
||||||
if (curpolyidx!=prevpolyidx) {
|
if (curpolyidx != prevpolyidx) {
|
||||||
if (curpolyidx!=prevpolyidx+1) {
|
if (curpolyidx != prevpolyidx + 1) {
|
||||||
printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
|
printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dmesh = dmesh==NULL ? dmeshes : dmesh+4;
|
dmesh = dmesh == NULL ? dmeshes : dmesh + 4;
|
||||||
dmesh[2] = (unsigned short)i; //tbase
|
dmesh[2] = (unsigned short)i; /* tbase */
|
||||||
dmesh[3] = 0; //tnum
|
dmesh[3] = 0; /* tnum */
|
||||||
prevpolyidx = curpolyidx;
|
prevpolyidx = curpolyidx;
|
||||||
}
|
}
|
||||||
dmesh[3]++;
|
dmesh[3]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//create navigation polygons
|
/* create navigation polygons */
|
||||||
vertsPerPoly = 6;
|
vertsPerPoly = 6;
|
||||||
polys = MEM_callocN(sizeof(unsigned short)*npolys*vertsPerPoly*2, "buildNavMeshData polys");
|
polys = MEM_callocN(sizeof(unsigned short) * npolys * vertsPerPoly * 2, "buildNavMeshData polys");
|
||||||
memset(polys, 0xff, sizeof(unsigned short)*vertsPerPoly*2*npolys);
|
memset(polys, 0xff, sizeof(unsigned short) * vertsPerPoly * 2 * npolys);
|
||||||
|
|
||||||
buildPolygonsByDetailedMeshes(vertsPerPoly, npolys, polys, dmeshes, verts, dtris, dtrisToPolysMap);
|
buildPolygonsByDetailedMeshes(vertsPerPoly, npolys, polys, dmeshes, verts, dtris, dtrisToPolysMap);
|
||||||
|
|
||||||
@@ -429,16 +429,16 @@ int buildNavMeshData(const int nverts, const float* verts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
|
int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
|
||||||
int *nverts, float **verts,
|
int *nverts, float **verts,
|
||||||
int *ndtris, unsigned short **dtris,
|
int *ndtris, unsigned short **dtris,
|
||||||
int *npolys, unsigned short **dmeshes,
|
int *npolys, unsigned short **dmeshes,
|
||||||
unsigned short **polys, int **dtrisToPolysMap,
|
unsigned short **polys, int **dtrisToPolysMap,
|
||||||
int **dtrisToTrisMap, int **trisToFacesMap)
|
int **dtrisToTrisMap, int **trisToFacesMap)
|
||||||
{
|
{
|
||||||
int res = 1;
|
int res = 1;
|
||||||
int ntris = 0, *recastData=NULL;
|
int ntris = 0, *recastData = NULL;
|
||||||
unsigned short *tris=NULL;
|
unsigned short *tris = NULL;
|
||||||
|
|
||||||
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
|
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
@@ -447,8 +447,8 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
|
res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
|
||||||
ndtris, dtris, npolys, dmeshes, polys, vertsPerPoly,
|
ndtris, dtris, npolys, dmeshes, polys, vertsPerPoly,
|
||||||
dtrisToPolysMap, dtrisToTrisMap);
|
dtrisToPolysMap, dtrisToTrisMap);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
|
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -461,11 +461,11 @@ exit:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx)
|
int polyFindVertex(const unsigned short *p, const int vertsPerPoly, unsigned short vertexIdx)
|
||||||
{
|
{
|
||||||
int i, res = -1;
|
int i, res = -1;
|
||||||
for (i=0; i<vertsPerPoly; i++) {
|
for (i = 0; i < vertsPerPoly; i++) {
|
||||||
if (p[i]==0xffff)
|
if (p[i] == 0xffff)
|
||||||
break;
|
break;
|
||||||
if (p[i] == vertexIdx) {
|
if (p[i] == vertexIdx) {
|
||||||
res = i;
|
res = i;
|
||||||
|
|||||||
@@ -810,7 +810,7 @@ static int bm_loop_reverse_loop(BMesh *bm, BMFace *f
|
|||||||
int bmesh_loop_reverse(BMesh *bm, BMFace *f)
|
int bmesh_loop_reverse(BMesh *bm, BMFace *f)
|
||||||
{
|
{
|
||||||
#ifdef USE_BMESH_HOLES
|
#ifdef USE_BMESH_HOLES
|
||||||
return bmesh_loop_reverse_loop(bm, f, f->loops.first);
|
return bm_loop_reverse_loop(bm, f, f->loops.first);
|
||||||
#else
|
#else
|
||||||
return bm_loop_reverse_loop(bm, f);
|
return bm_loop_reverse_loop(bm, f);
|
||||||
#endif
|
#endif
|
||||||
@@ -1186,13 +1186,15 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
|
|||||||
{
|
{
|
||||||
#ifdef USE_BMESH_HOLES
|
#ifdef USE_BMESH_HOLES
|
||||||
BMLoopList *lst, *lst2;
|
BMLoopList *lst, *lst2;
|
||||||
|
#else
|
||||||
|
int first_loop_f1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BMFace *f2;
|
BMFace *f2;
|
||||||
BMLoop *l_iter, *l_first;
|
BMLoop *l_iter, *l_first;
|
||||||
BMLoop *v1loop = NULL, *v2loop = NULL, *f1loop = NULL, *f2loop = NULL;
|
BMLoop *v1loop = NULL, *v2loop = NULL, *f1loop = NULL, *f2loop = NULL;
|
||||||
BMEdge *e;
|
BMEdge *e;
|
||||||
int i, len, f1len, f2len, first_loop_f1;
|
int i, len, f1len, f2len;
|
||||||
|
|
||||||
/* verify that v1 and v2 are in face */
|
/* verify that v1 and v2 are in face */
|
||||||
len = f->len;
|
len = f->len;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize)
|
|||||||
bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER);
|
bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER);
|
||||||
|
|
||||||
#ifdef USE_BMESH_HOLES
|
#ifdef USE_BMESH_HOLES
|
||||||
bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE);
|
bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), 512, 512, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* allocate one flag pool that we don't get rid of. */
|
/* allocate one flag pool that we don't get rid of. */
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//a bit of cleaner code that, alas, doens't work.
|
/* a bit of cleaner code that, alas, doens't work. */
|
||||||
/* build edge tag */
|
/* build edge tag */
|
||||||
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
|
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
|
||||||
if (BMO_elem_flag_test(bm, e->v1, BEVEL_FLAG) || BMO_elem_flag_test(bm, e->v2, BEVEL_FLAG)) {
|
if (BMO_elem_flag_test(bm, e->v1, BEVEL_FLAG) || BMO_elem_flag_test(bm, e->v2, BEVEL_FLAG)) {
|
||||||
|
|||||||
@@ -1019,10 +1019,9 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
|
|||||||
|
|
||||||
void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
|
void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
|
||||||
{
|
{
|
||||||
BMOIter fs_iter; /* selected faces iterator */
|
BMOIter fs_iter; /* selected faces iterator */
|
||||||
BMFace *fs; /* current face */
|
BMFace *fs; /* current face */
|
||||||
BMIter l_iter; /* iteration loop */
|
BMIter l_iter; /* iteration loop */
|
||||||
// int n;
|
|
||||||
|
|
||||||
int dir = BMO_slot_int_get(op, "dir");
|
int dir = BMO_slot_int_get(op, "dir");
|
||||||
|
|
||||||
@@ -1077,7 +1076,6 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************** *
|
/**************************************************************************** *
|
||||||
@@ -1126,10 +1124,9 @@ void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op)
|
|||||||
|
|
||||||
void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
|
void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
|
||||||
{
|
{
|
||||||
BMOIter fs_iter; /* selected faces iterator */
|
BMOIter fs_iter; /* selected faces iterator */
|
||||||
BMFace *fs; /* current face */
|
BMFace *fs; /* current face */
|
||||||
BMIter l_iter; /* iteration loop */
|
BMIter l_iter; /* iteration loop */
|
||||||
// int n;
|
|
||||||
|
|
||||||
int dir = BMO_slot_int_get(op, "dir");
|
int dir = BMO_slot_int_get(op, "dir");
|
||||||
|
|
||||||
|
|||||||
@@ -645,7 +645,7 @@ static PyGetSetDef bpy_bmface_getseters[] = {
|
|||||||
|
|
||||||
static PyGetSetDef bpy_bmloop_getseters[] = {
|
static PyGetSetDef bpy_bmloop_getseters[] = {
|
||||||
/* generic */
|
/* generic */
|
||||||
// flags are available but not used for loops.
|
/* flags are available but not used for loops. */
|
||||||
// {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
|
// {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
|
||||||
// {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN},
|
// {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN},
|
||||||
{(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG},
|
{(char *)"tag", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_tag_doc, (void *)BM_ELEM_TAG},
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ void BPy_BM_init_types_select(void)
|
|||||||
BPy_BMEditSelSeq_Type.tp_name = "BMEditSelSeq";
|
BPy_BMEditSelSeq_Type.tp_name = "BMEditSelSeq";
|
||||||
BPy_BMEditSelIter_Type.tp_name = "BMEditSelIter";
|
BPy_BMEditSelIter_Type.tp_name = "BMEditSelIter";
|
||||||
|
|
||||||
BPy_BMEditSelSeq_Type.tp_doc = NULL; // todo
|
BPy_BMEditSelSeq_Type.tp_doc = NULL; /* todo */
|
||||||
BPy_BMEditSelIter_Type.tp_doc = NULL;
|
BPy_BMEditSelIter_Type.tp_doc = NULL;
|
||||||
|
|
||||||
BPy_BMEditSelSeq_Type.tp_repr = (reprfunc)NULL;
|
BPy_BMEditSelSeq_Type.tp_repr = (reprfunc)NULL;
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
|
|||||||
if (PyList_GET_SIZE(cb_list) > 0) {
|
if (PyList_GET_SIZE(cb_list) > 0) {
|
||||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||||
|
|
||||||
PyObject *args = PyTuple_New(1); // save python creating each call
|
PyObject *args = PyTuple_New(1); /* save python creating each call */
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
Py_ssize_t pos;
|
Py_ssize_t pos;
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0 // slow, with this can avoid all Py_CompileString above.
|
#if 0 /* slow, with this can avoid all Py_CompileString above. */
|
||||||
/* execute expression to get a value */
|
/* execute expression to get a value */
|
||||||
retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars);
|
retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
#include "BPY_extern.h"
|
#include "BPY_extern.h"
|
||||||
|
|
||||||
#include "../generic/bpy_internal_import.h" // our own imports
|
#include "../generic/bpy_internal_import.h" /* our own imports */
|
||||||
#include "../generic/py_capi_utils.h"
|
#include "../generic/py_capi_utils.h"
|
||||||
|
|
||||||
/* inittab initialization functions */
|
/* inittab initialization functions */
|
||||||
@@ -180,10 +180,10 @@ void BPY_text_free_code(Text *text)
|
|||||||
|
|
||||||
void BPY_modules_update(bContext *C)
|
void BPY_modules_update(bContext *C)
|
||||||
{
|
{
|
||||||
#if 0 // slow, this runs all the time poll, draw etc 100's of time a sec.
|
#if 0 /* slow, this runs all the time poll, draw etc 100's of time a sec. */
|
||||||
PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
|
PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
|
||||||
PyModule_AddObject(mod, "data", BPY_rna_module());
|
PyModule_AddObject(mod, "data", BPY_rna_module());
|
||||||
PyModule_AddObject(mod, "types", BPY_rna_types()); // atm this does not need updating
|
PyModule_AddObject(mod, "types", BPY_rna_types()); /* atm this does not need updating */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* refreshes the main struct */
|
/* refreshes the main struct */
|
||||||
@@ -268,7 +268,7 @@ void BPY_python_start(int argc, const char **argv)
|
|||||||
|
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
|
|
||||||
// PySys_SetArgv(argc, argv); // broken in py3, not a huge deal
|
// PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
|
||||||
/* sigh, why do python guys not have a (char **) version anymore? */
|
/* sigh, why do python guys not have a (char **) version anymore? */
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const short
|
|||||||
short BPy_errors_to_report(ReportList *reports)
|
short BPy_errors_to_report(ReportList *reports)
|
||||||
{
|
{
|
||||||
PyObject *pystring;
|
PyObject *pystring;
|
||||||
PyObject *pystring_format = NULL; // workaround, see below
|
PyObject *pystring_format = NULL; /* workaround, see below */
|
||||||
char *cstring;
|
char *cstring;
|
||||||
|
|
||||||
const char *filename;
|
const char *filename;
|
||||||
@@ -110,17 +110,18 @@ short BPy_errors_to_report(ReportList *reports)
|
|||||||
|
|
||||||
cstring = _PyUnicode_AsString(pystring);
|
cstring = _PyUnicode_AsString(pystring);
|
||||||
|
|
||||||
#if 0 // ARG!. workaround for a bug in blenders use of vsnprintf
|
#if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */
|
||||||
BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno);
|
BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno);
|
||||||
#else
|
#else
|
||||||
pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation:%s:%d\n"), cstring, filename, lineno);
|
pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation:%s:%d\n"), cstring, filename, lineno);
|
||||||
cstring = _PyUnicode_AsString(pystring_format);
|
cstring = _PyUnicode_AsString(pystring_format);
|
||||||
BKE_report(reports, RPT_ERROR, cstring);
|
BKE_report(reports, RPT_ERROR, cstring);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, TIP_("%s\nlocation:%s:%d\n"), cstring, filename, lineno); // not exactly needed. just for testing
|
/* not exactly needed. just for testing */
|
||||||
|
fprintf(stderr, TIP_("%s\nlocation:%s:%d\n"), cstring, filename, lineno);
|
||||||
|
|
||||||
Py_DECREF(pystring);
|
Py_DECREF(pystring);
|
||||||
Py_DECREF(pystring_format); // workaround
|
Py_DECREF(pystring_format); /* workaround */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ typedef struct SunSky {
|
|||||||
float atm_BetaRM[3];
|
float atm_BetaRM[3];
|
||||||
} SunSky;
|
} SunSky;
|
||||||
|
|
||||||
void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness,
|
void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float horizon_brightness,
|
||||||
float spread, float sun_brightness, float sun_size, float back_scatter,
|
float spread, float sun_brightness, float sun_size, float back_scatter,
|
||||||
float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace);
|
float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace);
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,9 @@
|
|||||||
* ***** END GPL LICENSE BLOCK *****
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ocean_texture(struct Tex *tex, float *texvec, struct TexResult *texres);
|
#ifndef __TEXTURE_OCEAN_H__
|
||||||
|
#define __TEXTURE_OCEAN_H__
|
||||||
|
|
||||||
|
int ocean_texture(struct Tex *tex, const float texvec[2], struct TexResult *texres);
|
||||||
|
|
||||||
|
#endif /* __TEXTURE_OCEAN_H__ */
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float *bbmin, float *bbmax);
|
void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float bbmin[3], float bbmax[3]);
|
||||||
int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, float *co);
|
int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, const float co[3]);
|
||||||
|
|
||||||
void volume_precache(Render *re);
|
void volume_precache(Render *re);
|
||||||
void free_volume_precache(Render *re);
|
void free_volume_precache(Render *re);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ static float PerezFunction(struct SunSky *sunsky, const float *lam, float theta,
|
|||||||
* sun_size, controls sun's size
|
* sun_size, controls sun's size
|
||||||
* back_scatter, controls back scatter light
|
* back_scatter, controls back scatter light
|
||||||
* */
|
* */
|
||||||
void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness,
|
void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float horizon_brightness,
|
||||||
float spread, float sun_brightness, float sun_size, float back_scatter,
|
float spread, float sun_brightness, float sun_size, float back_scatter,
|
||||||
float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace)
|
float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ extern struct Render R;
|
|||||||
|
|
||||||
|
|
||||||
/* ***** actual texture sampling ***** */
|
/* ***** actual texture sampling ***** */
|
||||||
int ocean_texture(Tex *tex, float *texvec, TexResult *texres)
|
int ocean_texture(Tex *tex, const float texvec[2], TexResult *texres)
|
||||||
{
|
{
|
||||||
OceanTex *ot = tex->ot;
|
OceanTex *ot = tex->ot;
|
||||||
ModifierData *md;
|
ModifierData *md;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ static int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Uses ray tracing to check if a point is inside or outside an ObjectInstanceRen */
|
/* Uses ray tracing to check if a point is inside or outside an ObjectInstanceRen */
|
||||||
static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), float *co)
|
static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), const float co[3])
|
||||||
{
|
{
|
||||||
Isect isect= {{0}};
|
Isect isect= {{0}};
|
||||||
float dir[3] = {0.0f, 0.0f, 1.0f};
|
float dir[3] = {0.0f, 0.0f, 1.0f};
|
||||||
@@ -118,7 +118,7 @@ static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), flo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* find the bounding box of an objectinstance in global space */
|
/* find the bounding box of an objectinstance in global space */
|
||||||
void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float *bbmin, float *bbmax)
|
void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float bbmin[3], float bbmax[3])
|
||||||
{
|
{
|
||||||
ObjectRen *obr = obi->obr;
|
ObjectRen *obr = obi->obr;
|
||||||
VolumePrecache *vp = obi->volume_precache;
|
VolumePrecache *vp = obi->volume_precache;
|
||||||
@@ -826,7 +826,7 @@ void free_volume_precache(Render *re)
|
|||||||
BLI_freelistN(&re->volumes);
|
BLI_freelistN(&re->volumes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, float *co)
|
int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, const float co[3])
|
||||||
{
|
{
|
||||||
RayObject *tree;
|
RayObject *tree;
|
||||||
int inside=0;
|
int inside=0;
|
||||||
|
|||||||
Reference in New Issue
Block a user