forked from bartvdbraak/blender
misc macro --> bli math lib functions
This commit is contained in:
parent
0634d8a745
commit
ec3b0c6a96
@ -48,27 +48,27 @@
|
|||||||
|
|
||||||
/* Math stuff for ray casting on mesh faces and for nearest surface */
|
/* Math stuff for ray casting on mesh faces and for nearest surface */
|
||||||
|
|
||||||
static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float *v0, const float *v1, const float *v2)
|
static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float v0[3], const float v1[3], const float v2[3])
|
||||||
{
|
{
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
if(isect_ray_tri_v3((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL))
|
if(isect_ray_tri_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL))
|
||||||
return dist;
|
return dist;
|
||||||
|
|
||||||
return FLT_MAX;
|
return FLT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, const float m_dist, const float *v0, const float *v1, const float *v2)
|
static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3])
|
||||||
{
|
{
|
||||||
|
|
||||||
float idist;
|
float idist;
|
||||||
float p1[3];
|
float p1[3];
|
||||||
float plane_normal[3], hit_point[3];
|
float plane_normal[3], hit_point[3];
|
||||||
|
|
||||||
normal_tri_v3( plane_normal,(float*)v0, (float*)v1, (float*)v2);
|
normal_tri_v3(plane_normal, v0, v1, v2);
|
||||||
|
|
||||||
VECADDFAC( p1, ray->origin, ray->direction, m_dist);
|
madd_v3_v3v3fl(p1, ray->origin, ray->direction, m_dist);
|
||||||
if(isect_sweeping_sphere_tri_v3((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point))
|
if(isect_sweeping_sphere_tri_v3(ray->origin, p1, radius, v0, v1, v2, &idist, hit_point))
|
||||||
{
|
{
|
||||||
return idist * m_dist;
|
return idist * m_dist;
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con
|
|||||||
* Function adapted from David Eberly's distance tools (LGPL)
|
* Function adapted from David Eberly's distance tools (LGPL)
|
||||||
* http://www.geometrictools.com/LibFoundation/Distance/Distance.html
|
* http://www.geometrictools.com/LibFoundation/Distance/Distance.html
|
||||||
*/
|
*/
|
||||||
static float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *nearest )
|
static float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const float v2[3], const float p[3], int *v, int *e, float nearest[3])
|
||||||
{
|
{
|
||||||
float diff[3];
|
float diff[3];
|
||||||
float e0[3];
|
float e0[3];
|
||||||
@ -98,16 +98,16 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const
|
|||||||
float sqrDist;
|
float sqrDist;
|
||||||
int lv = -1, le = -1;
|
int lv = -1, le = -1;
|
||||||
|
|
||||||
VECSUB(diff, v0, p);
|
sub_v3_v3v3(diff, v0, p);
|
||||||
VECSUB(e0, v1, v0);
|
sub_v3_v3v3(e0, v1, v0);
|
||||||
VECSUB(e1, v2, v0);
|
sub_v3_v3v3(e1, v2, v0);
|
||||||
|
|
||||||
A00 = INPR ( e0, e0 );
|
A00 = dot_v3v3(e0, e0);
|
||||||
A01 = INPR( e0, e1 );
|
A01 = dot_v3v3(e0, e1 );
|
||||||
A11 = INPR ( e1, e1 );
|
A11 = dot_v3v3(e1, e1 );
|
||||||
B0 = INPR( diff, e0 );
|
B0 = dot_v3v3(diff, e0 );
|
||||||
B1 = INPR( diff, e1 );
|
B1 = dot_v3v3(diff, e1 );
|
||||||
C = INPR( diff, diff );
|
C = dot_v3v3(diff, diff );
|
||||||
Det = fabs( A00 * A11 - A01 * A01 );
|
Det = fabs( A00 * A11 - A01 * A01 );
|
||||||
S = A01 * B1 - A11 * B0;
|
S = A01 * B1 - A11 * B0;
|
||||||
T = A01 * B0 - A00 * B1;
|
T = A01 * B0 - A00 * B1;
|
||||||
@ -123,7 +123,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const
|
|||||||
T = 0.0f;
|
T = 0.0f;
|
||||||
if ( -B0 >= A00 )
|
if ( -B0 >= A00 )
|
||||||
{
|
{
|
||||||
S = (float)1.0;
|
S = 1.0f;
|
||||||
sqrDist = A00 + 2.0f * B0 + C;
|
sqrDist = A00 + 2.0f * B0 + C;
|
||||||
lv = 1;
|
lv = 1;
|
||||||
}
|
}
|
||||||
@ -379,15 +379,15 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const
|
|||||||
|
|
||||||
{
|
{
|
||||||
float w[3], x[3], y[3], z[3];
|
float w[3], x[3], y[3], z[3];
|
||||||
VECCOPY(w, v0);
|
copy_v3_v3(w, v0);
|
||||||
VECCOPY(x, e0);
|
copy_v3_v3(x, e0);
|
||||||
mul_v3_fl(x, S);
|
mul_v3_fl(x, S);
|
||||||
VECCOPY(y, e1);
|
copy_v3_v3(y, e1);
|
||||||
mul_v3_fl(y, T);
|
mul_v3_fl(y, T);
|
||||||
VECADD(z, w, x);
|
VECADD(z, w, x);
|
||||||
VECADD(z, z, y);
|
VECADD(z, z, y);
|
||||||
//VECSUB(d, p, z);
|
//sub_v3_v3v3(d, p, z);
|
||||||
VECCOPY(nearest, z);
|
copy_v3_v3(nearest, z);
|
||||||
// d = p - ( v0 + S * e0 + T * e1 );
|
// d = p - ( v0 + S * e0 + T * e1 );
|
||||||
}
|
}
|
||||||
*v = lv;
|
*v = lv;
|
||||||
@ -403,7 +403,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const
|
|||||||
|
|
||||||
// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces.
|
// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces.
|
||||||
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
||||||
static void mesh_faces_nearest_point(void *userdata, int index, const float *co, BVHTreeNearest *nearest)
|
static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
|
||||||
{
|
{
|
||||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
||||||
MVert *vert = data->vert;
|
MVert *vert = data->vert;
|
||||||
@ -426,7 +426,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co,
|
|||||||
{
|
{
|
||||||
nearest->index = index;
|
nearest->index = index;
|
||||||
nearest->dist = dist;
|
nearest->dist = dist;
|
||||||
VECCOPY(nearest->co, nearest_tmp);
|
copy_v3_v3(nearest->co, nearest_tmp);
|
||||||
normal_tri_v3( nearest->no,t0, t1, t2);
|
normal_tri_v3( nearest->no,t0, t1, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +464,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
|
|||||||
{
|
{
|
||||||
hit->index = index;
|
hit->index = index;
|
||||||
hit->dist = dist;
|
hit->dist = dist;
|
||||||
VECADDFAC(hit->co, ray->origin, ray->direction, dist);
|
madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
|
||||||
|
|
||||||
normal_tri_v3( hit->no,t0, t1, t2);
|
normal_tri_v3( hit->no,t0, t1, t2);
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
|
|||||||
|
|
||||||
// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges.
|
// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges.
|
||||||
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
|
||||||
static void mesh_edges_nearest_point(void *userdata, int index, const float *co, BVHTreeNearest *nearest)
|
static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
|
||||||
{
|
{
|
||||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata;
|
||||||
MVert *vert = data->vert;
|
MVert *vert = data->vert;
|
||||||
@ -489,15 +489,14 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co,
|
|||||||
t0 = vert[ edge->v1 ].co;
|
t0 = vert[ edge->v1 ].co;
|
||||||
t1 = vert[ edge->v2 ].co;
|
t1 = vert[ edge->v2 ].co;
|
||||||
|
|
||||||
// NOTE: casts to "float*" here are due to co being "const float*"
|
closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
|
||||||
closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1);
|
dist = len_squared_v3v3(nearest_tmp, co);
|
||||||
dist = len_squared_v3v3(nearest_tmp, (float*)co);
|
|
||||||
|
|
||||||
if(dist < nearest->dist)
|
if(dist < nearest->dist)
|
||||||
{
|
{
|
||||||
nearest->index = index;
|
nearest->index = index;
|
||||||
nearest->dist = dist;
|
nearest->dist = dist;
|
||||||
VECCOPY(nearest->co, nearest_tmp);
|
copy_v3_v3(nearest->co, nearest_tmp);
|
||||||
sub_v3_v3v3(nearest->no, t0, t1);
|
sub_v3_v3v3(nearest->no, t0, t1);
|
||||||
normalize_v3(nearest->no);
|
normalize_v3(nearest->no);
|
||||||
}
|
}
|
||||||
@ -590,11 +589,11 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
|||||||
for(i = 0; i < numFaces; i++, efa= efa->next) {
|
for(i = 0; i < numFaces; i++, efa= efa->next) {
|
||||||
if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) {
|
if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) {
|
||||||
float co[4][3];
|
float co[4][3];
|
||||||
VECCOPY(co[0], vert[ face[i].v1 ].co);
|
copy_v3_v3(co[0], vert[ face[i].v1 ].co);
|
||||||
VECCOPY(co[1], vert[ face[i].v2 ].co);
|
copy_v3_v3(co[1], vert[ face[i].v2 ].co);
|
||||||
VECCOPY(co[2], vert[ face[i].v3 ].co);
|
copy_v3_v3(co[2], vert[ face[i].v3 ].co);
|
||||||
if(face[i].v4)
|
if(face[i].v4)
|
||||||
VECCOPY(co[3], vert[ face[i].v4 ].co);
|
copy_v3_v3(co[3], vert[ face[i].v4 ].co);
|
||||||
|
|
||||||
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
|
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
|
||||||
}
|
}
|
||||||
@ -603,11 +602,11 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
|||||||
else {
|
else {
|
||||||
for(i = 0; i < numFaces; i++) {
|
for(i = 0; i < numFaces; i++) {
|
||||||
float co[4][3];
|
float co[4][3];
|
||||||
VECCOPY(co[0], vert[ face[i].v1 ].co);
|
copy_v3_v3(co[0], vert[ face[i].v1 ].co);
|
||||||
VECCOPY(co[1], vert[ face[i].v2 ].co);
|
copy_v3_v3(co[1], vert[ face[i].v2 ].co);
|
||||||
VECCOPY(co[2], vert[ face[i].v3 ].co);
|
copy_v3_v3(co[2], vert[ face[i].v3 ].co);
|
||||||
if(face[i].v4)
|
if(face[i].v4)
|
||||||
VECCOPY(co[3], vert[ face[i].v4 ].co);
|
copy_v3_v3(co[3], vert[ face[i].v4 ].co);
|
||||||
|
|
||||||
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
|
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
|
||||||
}
|
}
|
||||||
@ -669,8 +668,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
|
|||||||
for(i = 0; i < numEdges; i++)
|
for(i = 0; i < numEdges; i++)
|
||||||
{
|
{
|
||||||
float co[4][3];
|
float co[4][3];
|
||||||
VECCOPY(co[0], vert[ edge[i].v1 ].co);
|
copy_v3_v3(co[0], vert[ edge[i].v1 ].co);
|
||||||
VECCOPY(co[1], vert[ edge[i].v2 ].co);
|
copy_v3_v3(co[1], vert[ edge[i].v2 ].co);
|
||||||
|
|
||||||
BLI_bvhtree_insert(tree, i, co[0], 2);
|
BLI_bvhtree_insert(tree, i, co[0], 2);
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
|
|||||||
|
|
||||||
hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
|
hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
|
||||||
/* clip handle point */
|
/* clip handle point */
|
||||||
VECCOPY(vec, bezt[1].vec[0]);
|
copy_v3_v3(vec, bezt[1].vec[0]);
|
||||||
if(vec[0] < bezt[0].vec[1][0])
|
if(vec[0] < bezt[0].vec[1][0])
|
||||||
vec[0]= bezt[0].vec[1][0];
|
vec[0]= bezt[0].vec[1][0];
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
|
|||||||
|
|
||||||
hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
|
hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
|
||||||
/* clip handle point */
|
/* clip handle point */
|
||||||
VECCOPY(vec, bezt[a-1].vec[2]);
|
copy_v3_v3(vec, bezt[a-1].vec[2]);
|
||||||
if(vec[0] > bezt[a].vec[1][0])
|
if(vec[0] > bezt[a].vec[1][0])
|
||||||
vec[0]= bezt[a].vec[1][0];
|
vec[0]= bezt[a].vec[1][0];
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
|
|||||||
if(a==0 && dl->type== DL_POLY) bezt= nu->bezt;
|
if(a==0 && dl->type== DL_POLY) bezt= nu->bezt;
|
||||||
|
|
||||||
if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
|
if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
|
||||||
VECCOPY(data, prevbezt->vec[1]);
|
copy_v3_v3(data, prevbezt->vec[1]);
|
||||||
data+= 3;
|
data+= 3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -363,7 +363,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(a==0 && dl->type==DL_SEGM) {
|
if(a==0 && dl->type==DL_SEGM) {
|
||||||
VECCOPY(data, bezt->vec[1]);
|
copy_v3_v3(data, bezt->vec[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
prevbezt= bezt;
|
prevbezt= bezt;
|
||||||
@ -404,7 +404,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
|
|||||||
a= len;
|
a= len;
|
||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
VECCOPY(data, bp->vec);
|
copy_v3_v3(data, bp->vec);
|
||||||
bp++;
|
bp++;
|
||||||
data+= 3;
|
data+= 3;
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
|
|||||||
totvert= 0;
|
totvert= 0;
|
||||||
eve= fillvertbase.first;
|
eve= fillvertbase.first;
|
||||||
while(eve) {
|
while(eve) {
|
||||||
VECCOPY(f1, eve->co);
|
copy_v3_v3(f1, eve->co);
|
||||||
f1+= 3;
|
f1+= 3;
|
||||||
|
|
||||||
/* index number */
|
/* index number */
|
||||||
@ -559,7 +559,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
|
|||||||
|
|
||||||
a= dl->parts;
|
a= dl->parts;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
VECCOPY(fp1, fp);
|
copy_v3_v3(fp1, fp);
|
||||||
fp1+= 3;
|
fp1+= 3;
|
||||||
fp+= dpoly;
|
fp+= dpoly;
|
||||||
}
|
}
|
||||||
@ -579,7 +579,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
|
|||||||
|
|
||||||
a= dl->parts;
|
a= dl->parts;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
VECCOPY(fp1, fp);
|
copy_v3_v3(fp1, fp);
|
||||||
fp1+= 3;
|
fp1+= 3;
|
||||||
fp+= dpoly;
|
fp+= dpoly;
|
||||||
}
|
}
|
||||||
|
@ -2120,7 +2120,7 @@ void object_set_dimensions(Object *ob, const float *value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void minmax_object(Object *ob, float *min, float *max)
|
void minmax_object(Object *ob, float min[3], float max[3])
|
||||||
{
|
{
|
||||||
BoundBox bb;
|
BoundBox bb;
|
||||||
float vec[3];
|
float vec[3];
|
||||||
|
@ -469,7 +469,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
|
|||||||
if(calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE)
|
if(calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE)
|
||||||
{
|
{
|
||||||
//Make the vertex stay on the front side of the face
|
//Make the vertex stay on the front side of the face
|
||||||
VECADDFAC(tmp_co, nearest.co, nearest.no, calc->keepDist);
|
madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -816,7 +816,7 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
if (oldbezt) {
|
if (oldbezt) {
|
||||||
int j;
|
int j;
|
||||||
for (j= 0; j < 3; ++j) {
|
for (j= 0; j < 3; ++j) {
|
||||||
VECSUB(ofs[i], bezt->vec[j], oldbezt->vec[j]);
|
sub_v3_v3v3(ofs[i], bezt->vec[j], oldbezt->vec[j]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
ofs[i++][0]= bezt->alfa - oldbezt->alfa;
|
ofs[i++][0]= bezt->alfa - oldbezt->alfa;
|
||||||
@ -832,7 +832,7 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
while(a--) {
|
while(a--) {
|
||||||
oldbp= getKeyIndexOrig_bp(editnurb, bp);
|
oldbp= getKeyIndexOrig_bp(editnurb, bp);
|
||||||
if (oldbp) {
|
if (oldbp) {
|
||||||
VECSUB(ofs[i], bp->vec, oldbp->vec);
|
sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec);
|
||||||
ofs[i+1][0]= bp->alfa - oldbp->alfa;
|
ofs[i+1][0]= bp->alfa - oldbp->alfa;
|
||||||
}
|
}
|
||||||
i += 2;
|
i += 2;
|
||||||
@ -866,10 +866,10 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
oldbezt= getKeyIndexOrig_bezt(editnurb, bezt);
|
oldbezt= getKeyIndexOrig_bezt(editnurb, bezt);
|
||||||
|
|
||||||
for (j= 0; j < 3; ++j, ++i) {
|
for (j= 0; j < 3; ++j, ++i) {
|
||||||
VECCOPY(fp, bezt->vec[j]);
|
copy_v3_v3(fp, bezt->vec[j]);
|
||||||
|
|
||||||
if (restore && oldbezt) {
|
if (restore && oldbezt) {
|
||||||
VECCOPY(bezt->vec[j], oldbezt->vec[j]);
|
copy_v3_v3(bezt->vec[j], oldbezt->vec[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fp+= 3;
|
fp+= 3;
|
||||||
@ -890,12 +890,12 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
while(a--) {
|
while(a--) {
|
||||||
oldbp= getKeyIndexOrig_bp(editnurb, bp);
|
oldbp= getKeyIndexOrig_bp(editnurb, bp);
|
||||||
|
|
||||||
VECCOPY(fp, bp->vec);
|
copy_v3_v3(fp, bp->vec);
|
||||||
|
|
||||||
fp[3]= bp->alfa;
|
fp[3]= bp->alfa;
|
||||||
|
|
||||||
if(restore && oldbp) {
|
if(restore && oldbp) {
|
||||||
VECCOPY(bp->vec, oldbp->vec);
|
copy_v3_v3(bp->vec, oldbp->vec);
|
||||||
bp->alfa= oldbp->alfa;
|
bp->alfa= oldbp->alfa;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,10 +921,10 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
curofp= ofp + index;
|
curofp= ofp + index;
|
||||||
|
|
||||||
for (j= 0; j < 3; ++j, ++i) {
|
for (j= 0; j < 3; ++j, ++i) {
|
||||||
VECCOPY(fp, curofp);
|
copy_v3_v3(fp, curofp);
|
||||||
|
|
||||||
if(apply_offset) {
|
if(apply_offset) {
|
||||||
VECADD(fp, fp, ofs[i]);
|
add_v3_v3(fp, ofs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fp+= 3; curofp+= 3;
|
fp+= 3; curofp+= 3;
|
||||||
@ -933,7 +933,7 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
|
|
||||||
if(apply_offset) {
|
if(apply_offset) {
|
||||||
/* apply alfa offsets */
|
/* apply alfa offsets */
|
||||||
VECADD(fp, fp, ofs[i]);
|
add_v3_v3(fp, ofs[i]);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,7 +941,7 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
} else {
|
} else {
|
||||||
int j;
|
int j;
|
||||||
for (j= 0; j < 3; ++j, ++i) {
|
for (j= 0; j < 3; ++j, ++i) {
|
||||||
VECCOPY(fp, bezt->vec[j]);
|
copy_v3_v3(fp, bezt->vec[j]);
|
||||||
fp+= 3;
|
fp+= 3;
|
||||||
}
|
}
|
||||||
fp[0]= bezt->alfa;
|
fp[0]= bezt->alfa;
|
||||||
@ -959,15 +959,15 @@ static void calc_shapeKeys(Object *obedit)
|
|||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
curofp= ofp + index;
|
curofp= ofp + index;
|
||||||
VECCOPY(fp, curofp);
|
copy_v3_v3(fp, curofp);
|
||||||
fp[3]= curofp[3];
|
fp[3]= curofp[3];
|
||||||
|
|
||||||
if(apply_offset) {
|
if(apply_offset) {
|
||||||
VECADD(fp, fp, ofs[i]);
|
add_v3_v3(fp, ofs[i]);
|
||||||
fp[3]+=ofs[i+1][0];
|
fp[3]+=ofs[i+1][0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
VECCOPY(fp, bp->vec);
|
copy_v3_v3(fp, bp->vec);
|
||||||
fp[3]= bp->alfa;
|
fp[3]= bp->alfa;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2890,14 +2890,14 @@ static void subdividenurb(Object *obedit, int number_cuts)
|
|||||||
interp_v3_v3v3(vec+12, vec+3, vec+6, factor);
|
interp_v3_v3v3(vec+12, vec+3, vec+6, factor);
|
||||||
|
|
||||||
/* change handle of prev beztn */
|
/* change handle of prev beztn */
|
||||||
VECCOPY((beztn-1)->vec[2], vec);
|
copy_v3_v3((beztn-1)->vec[2], vec);
|
||||||
/* new point */
|
/* new point */
|
||||||
VECCOPY(beztn->vec[0], vec+9);
|
copy_v3_v3(beztn->vec[0], vec+9);
|
||||||
interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor);
|
interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor);
|
||||||
VECCOPY(beztn->vec[2], vec+12);
|
copy_v3_v3(beztn->vec[2], vec+12);
|
||||||
/* handle of next bezt */
|
/* handle of next bezt */
|
||||||
if(a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);}
|
if(a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);}
|
||||||
else {VECCOPY(bezt->vec[0], vec+6);}
|
else {copy_v3_v3(bezt->vec[0], vec+6);}
|
||||||
|
|
||||||
beztn->radius = (prevbezt->radius + bezt->radius)/2;
|
beztn->radius = (prevbezt->radius + bezt->radius)/2;
|
||||||
beztn->weight = (prevbezt->weight + bezt->weight)/2;
|
beztn->weight = (prevbezt->weight + bezt->weight)/2;
|
||||||
@ -3381,7 +3381,7 @@ static int convertspline(short type, Nurb *nu)
|
|||||||
a= nr;
|
a= nr;
|
||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
VECCOPY(bezt->vec[1], bp->vec);
|
copy_v3_v3(bezt->vec[1], bp->vec);
|
||||||
bezt->f1=bezt->f2=bezt->f3= bp->f1;
|
bezt->f1=bezt->f2=bezt->f3= bp->f1;
|
||||||
bezt->h1= bezt->h2= HD_VECT;
|
bezt->h1= bezt->h2= HD_VECT;
|
||||||
bezt->weight= bp->weight;
|
bezt->weight= bp->weight;
|
||||||
@ -3418,7 +3418,7 @@ static int convertspline(short type, Nurb *nu)
|
|||||||
while(a--) {
|
while(a--) {
|
||||||
if(type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
|
if(type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
|
||||||
/* vector handle becomes 1 poly vertice */
|
/* vector handle becomes 1 poly vertice */
|
||||||
VECCOPY(bp->vec, bezt->vec[1]);
|
copy_v3_v3(bp->vec, bezt->vec[1]);
|
||||||
bp->vec[3]= 1.0;
|
bp->vec[3]= 1.0;
|
||||||
bp->f1= bezt->f2;
|
bp->f1= bezt->f2;
|
||||||
nr-= 2;
|
nr-= 2;
|
||||||
@ -3428,7 +3428,7 @@ static int convertspline(short type, Nurb *nu)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(c=0;c<3;c++) {
|
for(c=0;c<3;c++) {
|
||||||
VECCOPY(bp->vec, bezt->vec[c]);
|
copy_v3_v3(bp->vec, bezt->vec[c]);
|
||||||
bp->vec[3]= 1.0;
|
bp->vec[3]= 1.0;
|
||||||
if(c==0) bp->f1= bezt->f1;
|
if(c==0) bp->f1= bezt->f1;
|
||||||
else if(c==1) bp->f1= bezt->f2;
|
else if(c==1) bp->f1= bezt->f2;
|
||||||
@ -3475,13 +3475,13 @@ static int convertspline(short type, Nurb *nu)
|
|||||||
a= nr;
|
a= nr;
|
||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
VECCOPY(bezt->vec[0], bp->vec);
|
copy_v3_v3(bezt->vec[0], bp->vec);
|
||||||
bezt->f1= bp->f1;
|
bezt->f1= bp->f1;
|
||||||
bp++;
|
bp++;
|
||||||
VECCOPY(bezt->vec[1], bp->vec);
|
copy_v3_v3(bezt->vec[1], bp->vec);
|
||||||
bezt->f2= bp->f1;
|
bezt->f2= bp->f1;
|
||||||
bp++;
|
bp++;
|
||||||
VECCOPY(bezt->vec[2], bp->vec);
|
copy_v3_v3(bezt->vec[2], bp->vec);
|
||||||
bezt->f3= bp->f1;
|
bezt->f3= bp->f1;
|
||||||
bezt->radius= bp->radius;
|
bezt->radius= bp->radius;
|
||||||
bezt->weight= bp->weight;
|
bezt->weight= bp->weight;
|
||||||
@ -4472,7 +4472,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
(BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
|
(BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
|
||||||
ED_curve_beztcpy(editnurb, newbezt, nu->bezt, nu->pntsu);
|
ED_curve_beztcpy(editnurb, newbezt, nu->bezt, nu->pntsu);
|
||||||
*(newbezt+nu->pntsu)= *bezt;
|
*(newbezt+nu->pntsu)= *bezt;
|
||||||
VECCOPY(temp, bezt->vec[1]);
|
copy_v3_v3(temp, bezt->vec[1]);
|
||||||
MEM_freeN(nu->bezt);
|
MEM_freeN(nu->bezt);
|
||||||
nu->bezt= newbezt;
|
nu->bezt= newbezt;
|
||||||
newbezt+= nu->pntsu;
|
newbezt+= nu->pntsu;
|
||||||
@ -4491,7 +4491,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
BEZ_SEL(newbezt);
|
BEZ_SEL(newbezt);
|
||||||
cu->lastsel= newbezt;
|
cu->lastsel= newbezt;
|
||||||
newbezt->h2= newbezt->h1;
|
newbezt->h2= newbezt->h1;
|
||||||
VECCOPY(temp, bezt->vec[1]);
|
copy_v3_v3(temp, bezt->vec[1]);
|
||||||
MEM_freeN(nu->bezt);
|
MEM_freeN(nu->bezt);
|
||||||
nu->bezt= newbezt;
|
nu->bezt= newbezt;
|
||||||
bezt= newbezt+1;
|
bezt= newbezt+1;
|
||||||
@ -4503,7 +4503,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
*newbezt= *bezt;
|
*newbezt= *bezt;
|
||||||
BEZ_SEL(newbezt);
|
BEZ_SEL(newbezt);
|
||||||
newbezt->h2= newbezt->h1;
|
newbezt->h2= newbezt->h1;
|
||||||
VECCOPY(temp, bezt->vec[1]);
|
copy_v3_v3(temp, bezt->vec[1]);
|
||||||
|
|
||||||
newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu");
|
newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu");
|
||||||
memcpy(newnu, nu, sizeof(Nurb));
|
memcpy(newnu, nu, sizeof(Nurb));
|
||||||
@ -6189,7 +6189,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
|
|||||||
|
|
||||||
if(rv3d) {
|
if(rv3d) {
|
||||||
copy_m4_m4(viewmat, rv3d->viewmat);
|
copy_m4_m4(viewmat, rv3d->viewmat);
|
||||||
VECCOPY(zvec, rv3d->viewinv[2]);
|
copy_v3_v3(zvec, rv3d->viewinv[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setflagsNurb(editnurb, 0);
|
setflagsNurb(editnurb, 0);
|
||||||
|
@ -2297,8 +2297,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
|
|||||||
ofs= key_to_vertcos(ob, kb);
|
ofs= key_to_vertcos(ob, kb);
|
||||||
|
|
||||||
/* calculate key coord offsets (from previous location) */
|
/* calculate key coord offsets (from previous location) */
|
||||||
for (a= 0; a < me->totvert; a++)
|
for (a= 0; a < me->totvert; a++) {
|
||||||
VECSUB(ofs[a], vertCos[a], ofs[a]);
|
sub_v3_v3v3(ofs[a], vertCos[a], ofs[a]);
|
||||||
|
}
|
||||||
|
|
||||||
/* apply offsets on other keys */
|
/* apply offsets on other keys */
|
||||||
currkey = me->key->block.first;
|
currkey = me->key->block.first;
|
||||||
|
@ -242,7 +242,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
|
|||||||
|
|
||||||
tstart();
|
tstart();
|
||||||
|
|
||||||
VECSUB(size, max, min);
|
sub_v3_v3v3(size, max, min);
|
||||||
|
|
||||||
// maxx, maxy, maxz
|
// maxx, maxy, maxz
|
||||||
cv[0][0] = max[0];
|
cv[0][0] = max[0];
|
||||||
|
@ -3882,7 +3882,7 @@ int Bevel(TransInfo *t, const int UNUSED(mval[2]))
|
|||||||
else {
|
else {
|
||||||
d = distance;
|
d = distance;
|
||||||
}
|
}
|
||||||
VECADDFAC(td->loc,td->center,td->axismtx[0],(*td->val)*d);
|
madd_v3_v3v3fl(td->loc, td->center, td->axismtx[0], (*td->val) * d);
|
||||||
}
|
}
|
||||||
|
|
||||||
recalcData(t);
|
recalcData(t);
|
||||||
|
@ -267,10 +267,10 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* uv angles */
|
/* uv angles */
|
||||||
VECSUB2D(av1, tf_uv[3], tf_uv[0]); normalize_v2(av1);
|
sub_v2_v2v2(av1, tf_uv[3], tf_uv[0]); normalize_v2(av1);
|
||||||
VECSUB2D(av2, tf_uv[0], tf_uv[1]); normalize_v2(av2);
|
sub_v2_v2v2(av2, tf_uv[0], tf_uv[1]); normalize_v2(av2);
|
||||||
VECSUB2D(av3, tf_uv[1], tf_uv[2]); normalize_v2(av3);
|
sub_v2_v2v2(av3, tf_uv[1], tf_uv[2]); normalize_v2(av3);
|
||||||
VECSUB2D(av4, tf_uv[2], tf_uv[3]); normalize_v2(av4);
|
sub_v2_v2v2(av4, tf_uv[2], tf_uv[3]); normalize_v2(av4);
|
||||||
|
|
||||||
/* This is the correct angle however we are only comparing angles
|
/* This is the correct angle however we are only comparing angles
|
||||||
* uvang1 = 90-((angle_normalized_v2v2(av1, av2) * RAD2DEGF(1.0f))-90);*/
|
* uvang1 = 90-((angle_normalized_v2v2(av1, av2) * RAD2DEGF(1.0f))-90);*/
|
||||||
@ -280,10 +280,10 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
|
|||||||
uvang4 = angle_normalized_v2v2(av4, av1);
|
uvang4 = angle_normalized_v2v2(av4, av1);
|
||||||
|
|
||||||
/* 3d angles */
|
/* 3d angles */
|
||||||
VECSUB(av1, efa->v4->co, efa->v1->co); normalize_v3(av1);
|
sub_v3_v3v3(av1, efa->v4->co, efa->v1->co); normalize_v3(av1);
|
||||||
VECSUB(av2, efa->v1->co, efa->v2->co); normalize_v3(av2);
|
sub_v3_v3v3(av2, efa->v1->co, efa->v2->co); normalize_v3(av2);
|
||||||
VECSUB(av3, efa->v2->co, efa->v3->co); normalize_v3(av3);
|
sub_v3_v3v3(av3, efa->v2->co, efa->v3->co); normalize_v3(av3);
|
||||||
VECSUB(av4, efa->v3->co, efa->v4->co); normalize_v3(av4);
|
sub_v3_v3v3(av4, efa->v3->co, efa->v4->co); normalize_v3(av4);
|
||||||
|
|
||||||
/* This is the correct angle however we are only comparing angles
|
/* This is the correct angle however we are only comparing angles
|
||||||
* ang1 = 90-((angle_normalized_v3v3(av1, av2) * RAD2DEGF(1.0f))-90);*/
|
* ang1 = 90-((angle_normalized_v3v3(av1, av2) * RAD2DEGF(1.0f))-90);*/
|
||||||
@ -328,9 +328,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* uv angles */
|
/* uv angles */
|
||||||
VECSUB2D(av1, tf_uv[2], tf_uv[0]); normalize_v2(av1);
|
sub_v2_v2v2(av1, tf_uv[2], tf_uv[0]); normalize_v2(av1);
|
||||||
VECSUB2D(av2, tf_uv[0], tf_uv[1]); normalize_v2(av2);
|
sub_v2_v2v2(av2, tf_uv[0], tf_uv[1]); normalize_v2(av2);
|
||||||
VECSUB2D(av3, tf_uv[1], tf_uv[2]); normalize_v2(av3);
|
sub_v2_v2v2(av3, tf_uv[1], tf_uv[2]); normalize_v2(av3);
|
||||||
|
|
||||||
/* This is the correct angle however we are only comparing angles
|
/* This is the correct angle however we are only comparing angles
|
||||||
* uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90); */
|
* uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90); */
|
||||||
@ -339,9 +339,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
|
|||||||
uvang3 = angle_normalized_v2v2(av3, av1);
|
uvang3 = angle_normalized_v2v2(av3, av1);
|
||||||
|
|
||||||
/* 3d angles */
|
/* 3d angles */
|
||||||
VECSUB(av1, efa->v3->co, efa->v1->co); normalize_v3(av1);
|
sub_v3_v3v3(av1, efa->v3->co, efa->v1->co); normalize_v3(av1);
|
||||||
VECSUB(av2, efa->v1->co, efa->v2->co); normalize_v3(av2);
|
sub_v3_v3v3(av2, efa->v1->co, efa->v2->co); normalize_v3(av2);
|
||||||
VECSUB(av3, efa->v2->co, efa->v3->co); normalize_v3(av3);
|
sub_v3_v3v3(av3, efa->v2->co, efa->v3->co); normalize_v3(av3);
|
||||||
/* This is the correct angle however we are only comparing angles
|
/* This is the correct angle however we are only comparing angles
|
||||||
* ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90); */
|
* ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90); */
|
||||||
ang1 = angle_normalized_v3v3(av1, av2);
|
ang1 = angle_normalized_v3v3(av1, av2);
|
||||||
|
@ -66,7 +66,7 @@ static void node_composit_exec_normal(void *UNUSED(data), bNode *node, bNodeStac
|
|||||||
if(in[0]->data==NULL) {
|
if(in[0]->data==NULL) {
|
||||||
VECCOPY(out[0]->vec, nor);
|
VECCOPY(out[0]->vec, nor);
|
||||||
/* render normals point inside... the widget points outside */
|
/* render normals point inside... the widget points outside */
|
||||||
out[1]->vec[0]= -INPR(out[0]->vec, in[0]->vec);
|
out[1]->vec[0]= -dot_v3v3(out[0]->vec, in[0]->vec);
|
||||||
}
|
}
|
||||||
else if(out[1]->hasoutput) {
|
else if(out[1]->hasoutput) {
|
||||||
/* make output size of input image */
|
/* make output size of input image */
|
||||||
|
@ -445,7 +445,7 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
|
|||||||
pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there.
|
pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there.
|
||||||
|
|
||||||
if(pchan) {
|
if(pchan) {
|
||||||
VECCOPY (pchan->loc, matrix[3]);
|
copy_v3_v3(pchan->loc, matrix[3]);
|
||||||
mat4_to_size(pchan->size, matrix);
|
mat4_to_size(pchan->size, matrix);
|
||||||
mat4_to_quat(pchan->quat, matrix);
|
mat4_to_quat(pchan->quat, matrix);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user