did math lib conversion, equivilent to merge with trunk/2.5 at r24464

This commit is contained in:
Joseph Eagar 2009-11-23 14:41:22 +00:00
commit 0e165c55bb
313 changed files with 6412 additions and 11927 deletions

@ -46,7 +46,7 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h" /* linknode */
#include "BLI_string.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BIF_gl.h"
#include "BLF_api.h"
@ -459,7 +459,7 @@ static void blf_font_fill(FontBLF *font)
font->pos[0]= 0.0f;
font->pos[1]= 0.0f;
font->angle= 0.0f;
Mat4One(font->mat);
unit_m4(font->mat);
font->clip_rec.xmin= 0.0f;
font->clip_rec.xmax= 0.0f;
font->clip_rec.ymin= 0.0f;

@ -38,7 +38,7 @@
#include "BKE_DerivedMesh.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "DNA_cloth_types.h"

@ -52,7 +52,7 @@ typedef struct bConstraintOb {
float startmat[4][4]; /* original matrix (before constraint solving) */
short type; /* type of owner */
short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_arithb.h) */
short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_math.h) */
} bConstraintOb;
/* ---------------------------------------------------------------------------- */

@ -42,7 +42,7 @@
#include "BKE_utildefines.h"
#include "BKE_bmesh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_cellalloc.h"
@ -89,7 +89,7 @@ BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Ve
else if (org != NULL) VECCOPY(vtd->org,org);
if (vec != NULL) {
VECCOPY(vtd->vec,vec);
Normalize(vtd->vec);
normalize_v3(vtd->vec);
}
vtd->loc = loc;
@ -262,7 +262,7 @@ static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge
nv = BME_SEMV(bm,v,e,ne);
if (nv == NULL) return NULL;
VECSUB(nv->co,v2->co,v->co);
len = VecLength(nv->co);
len = len_v3(nv->co);
VECADDFAC(nv->co,v->co,nv->co,len*percent);
nv->flag = v->flag;
nv->bweight = v->bweight;
@ -336,17 +336,17 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa
/* compare the transform origins to see if we can use the vert co's;
* if they belong to different origins, then we will use the origins to determine
* the vector */
if (VecCompare(vtd1->org,vtd2->org,0.000001f)) {
if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) {
VECSUB(vec,v2->co,v1->co);
if (VecLength(vec) < 0.000001f) {
VecMulf(vec,0);
if (len_v3(vec) < 0.000001f) {
mul_v3_fl(vec,0);
}
return 0;
}
else {
VECSUB(vec,vtd2->org,vtd1->org);
if (VecLength(vec) < 0.000001f) {
VecMulf(vec,0);
if (len_v3(vec) < 0.000001f) {
mul_v3_fl(vec,0);
}
return 1;
}
@ -364,18 +364,18 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa
static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td) {
float factor, vec3[3], tmp[3],c1,c2;
Crossf(tmp,vec1,vec2);
Normalize(tmp);
factor = Inpf(up_vec,tmp);
cross_v3_v3v3(tmp,vec1,vec2);
normalize_v3(tmp);
factor = dot_v3v3(up_vec,tmp);
if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) {
Crossf(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
}
else {
Crossf(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
}
Normalize(vec3);
c1 = Inpf(vec3,vec1);
c2 = Inpf(vec1,vec1);
normalize_v3(vec3);
c1 = dot_v3v3(vec3,vec1);
c2 = dot_v3v3(vec1,vec1);
if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) {
factor = 0.0f;
}
@ -436,8 +436,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
BME_bevel_get_vec(vec1,v1,v,td);
BME_bevel_get_vec(vec2,v2,v,td);
Crossf(t_up_vec,vec1,vec2);
Normalize(t_up_vec);
cross_v3_v3v3(t_up_vec,vec1,vec2);
normalize_v3(t_up_vec);
up_vec = t_up_vec;
}
else {
@ -487,8 +487,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */
BME_bevel_get_vec(vec2,v,v2,td); /* get the vector we will be projecting parallel to */
len = VecLength(vec1);
Normalize(vec1);
len = len_v3(vec1);
normalize_v3(vec1);
vtd = BME_get_transdata(td, sv);
vtd1 = BME_get_transdata(td, v);
@ -526,8 +526,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
}
VECADDFAC(sv->co,v->co,vec1,dis);
VECSUB(vec1,sv->co,vtd1->org);
dis = VecLength(vec1);
Normalize(vec1);
dis = len_v3(vec1);
normalize_v3(vec1);
BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max);
return sv;
@ -546,10 +546,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
}
else {
VECCOPY(vec2,vtd1->vec);
VecMulf(vec2,vtd1->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec2,vec1);
fac1 = VecLength(vec2)/value;
mul_v3_fl(vec2,vtd1->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec2,vec1);
fac1 = len_v3(vec2)/value;
}
else {
fac1 = 0;
@ -561,10 +561,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
}
else {
VECCOPY(vec3,vtd2->vec);
VecMulf(vec3,vtd2->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec3,vec1);
fac2 = VecLength(vec2)/value;
mul_v3_fl(vec3,vtd2->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec3,vec1);
fac2 = len_v3(vec2)/value;
}
else {
fac2 = 0;
@ -572,7 +572,7 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
}
if (fac1 || fac2) {
max = VecLength(vec1)/(fac1 + fac2);
max = len_v3(vec1)/(fac1 + fac2);
if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
*vtd1->max = max;
}
@ -761,12 +761,12 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
for (i=0,ol=f->loopbase,l=ol->next; l->next!=ol; l=l->next) {
BME_bevel_get_vec(vec1,l->next->v,ol->v,td);
BME_bevel_get_vec(vec2,l->v,ol->v,td);
Crossf(vec3,vec2,vec1);
cross_v3_v3v3(vec3,vec2,vec1);
VECADD(up_vec,up_vec,vec3);
i++;
}
VecMulf(up_vec,1.0f/i);
Normalize(up_vec);
mul_v3_fl(up_vec,1.0f/i);
normalize_v3(up_vec);
for (i=0,len=f->len; i<len; i++,l=l->next) {
if ((l->e->tflag1 & BME_BEVEL_BEVEL) && (l->e->tflag1 & BME_BEVEL_ORIG)) {
@ -792,10 +792,10 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
}
else {
VECCOPY(vec2,vtd1->vec);
VecMulf(vec2,vtd1->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec2,vec1);
fac1 = VecLength(vec2)/value;
mul_v3_fl(vec2,vtd1->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec2,vec1);
fac1 = len_v3(vec2)/value;
}
else {
fac1 = 0;
@ -806,17 +806,17 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
}
else {
VECCOPY(vec3,vtd2->vec);
VecMulf(vec3,vtd2->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec3,vec1);
fac2 = VecLength(vec2)/value;
mul_v3_fl(vec3,vtd2->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec3,vec1);
fac2 = len_v3(vec2)/value;
}
else {
fac2 = 0;
}
}
if (fac1 || fac2) {
max = VecLength(vec1)/(fac1 + fac2);
max = len_v3(vec1)/(fac1 + fac2);
if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
*vtd1->max = max;
}
@ -881,7 +881,7 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) {
}
VECSUB(vec1,v1->co,v->co);
VECSUB(vec2,v2->co,v->co);
Crossf(vec3,vec1,vec2);
cross_v3_v3v3(vec3,vec1,vec2);
l1 = l2;
if (l1->v == v) {
@ -894,12 +894,12 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) {
}
VECSUB(vec1,v1->co,v->co);
VECSUB(vec2,v2->co,v->co);
Crossf(vec4,vec2,vec1);
cross_v3_v3v3(vec4,vec2,vec1);
Normalize(vec3);
Normalize(vec4);
normalize_v3(vec3);
normalize_v3(vec4);
return Inpf(vec3,vec4);
return dot_v3v3(vec3,vec4);
}
static int BME_face_sharededges(BME_Poly *f1, BME_Poly *f2){
BME_Loop *l;

@ -52,7 +52,7 @@
#include "DNA_space_types.h"
#include "DNA_particle_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_editVert.h"
@ -833,20 +833,20 @@ static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[
{
if (vertexCos) {
VECCOPY(cent, vertexCos[(int) efa->v1->tmp.l]);
VecAddf(cent, cent, vertexCos[(int) efa->v2->tmp.l]);
VecAddf(cent, cent, vertexCos[(int) efa->v3->tmp.l]);
if (efa->v4) VecAddf(cent, cent, vertexCos[(int) efa->v4->tmp.l]);
add_v3_v3v3(cent, cent, vertexCos[(int) efa->v2->tmp.l]);
add_v3_v3v3(cent, cent, vertexCos[(int) efa->v3->tmp.l]);
if (efa->v4) add_v3_v3v3(cent, cent, vertexCos[(int) efa->v4->tmp.l]);
} else {
VECCOPY(cent, efa->v1->co);
VecAddf(cent, cent, efa->v2->co);
VecAddf(cent, cent, efa->v3->co);
if (efa->v4) VecAddf(cent, cent, efa->v4->co);
add_v3_v3v3(cent, cent, efa->v2->co);
add_v3_v3v3(cent, cent, efa->v3->co);
if (efa->v4) add_v3_v3v3(cent, cent, efa->v4->co);
}
if (efa->v4) {
VecMulf(cent, 0.25f);
mul_v3_fl(cent, 0.25f);
} else {
VecMulf(cent, 0.33333333333f);
mul_v3_fl(cent, 0.33333333333f);
}
}
static void emDM_foreachMappedFaceCenter(void *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData)
@ -1713,25 +1713,25 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob,
if(efa->v4) {
float *v4 = vertexCos[(int) efa->v4->tmp.l];
CalcNormFloat4(v1, v2, v3, v4, no);
VecAddf(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no);
normal_quad_v3( no,v1, v2, v3, v4);
add_v3_v3v3(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no);
}
else {
CalcNormFloat(v1, v2, v3, no);
normal_tri_v3( no,v1, v2, v3);
}
VecAddf(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no);
VecAddf(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no);
VecAddf(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no);
add_v3_v3v3(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no);
add_v3_v3v3(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no);
add_v3_v3v3(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no);
}
for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) {
float *no = emdm->vertexNos[i];
/* following Mesh convention; we use vertex coordinate itself
* for normal in this case */
if (Normalize(no)==0.0) {
if (normalize_v3(no)==0.0) {
VECCOPY(no, vertexCos[i]);
Normalize(no);
normalize_v3(no);
}
}
}
@ -2717,7 +2717,7 @@ int editbmesh_get_first_deform_matrices(Object *ob, BMEditMesh *em, float (**def
defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
for(a=0; a<numVerts; a++)
Mat3One(defmats[a]);
unit_m3(defmats[a]);
}
mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats,
@ -2789,11 +2789,11 @@ void DM_add_tangent_layer(DerivedMesh *dm)
if (mf->v4) {
v4= &mvert[mf->v4];
CalcNormFloat4(v4->co, v3->co, v2->co, v1->co, fno);
normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co);
}
else {
v4= NULL;
CalcNormFloat(v3->co, v2->co, v1->co, fno);
normal_tri_v3( fno,v3->co, v2->co, v1->co);
}
if(mtface) {
@ -2804,11 +2804,11 @@ void DM_add_tangent_layer(DerivedMesh *dm)
}
else {
uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3];
spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]);
spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]);
spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]);
map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
if(v4)
spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]);
map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
}
tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang);
@ -2838,11 +2838,11 @@ void DM_add_tangent_layer(DerivedMesh *dm)
}
else {
uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3];
spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]);
spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]);
spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]);
map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
if(len==4)
spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]);
map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
}
mf_vi[0]= mf->v1;
@ -2854,7 +2854,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
vtang= find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]);
VECCOPY(tangent[j], vtang);
Normalize(tangent[j]);
normalize_v3(tangent[j]);
}
}

@ -64,7 +64,7 @@
#include "BKE_utildefines.h"
#include "BIK_api.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
@ -453,7 +453,7 @@ bPoseChannel *verify_pose_channel(bPose* pose, const char* name)
chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f;
chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f;
chan->ikrotweight = chan->iklinweight = 0.0f;
Mat4One(chan->constinv);
unit_m4(chan->constinv);
BLI_addtail(&pose->chanbase, chan);
@ -611,8 +611,8 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
pchan->rotAngle= chan->rotAngle;
QUATCOPY(pchan->quat, chan->quat);
pchan->rotmode= chan->rotmode;
Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
Mat4CpyMat4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
pchan->flag= chan->flag;
con= chan->constraints.first;
@ -1013,8 +1013,8 @@ void copy_pose_result(bPose *to, bPose *from)
for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
pchanto= get_pose_channel(to, pchanfrom->name);
if(pchanto) {
Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat);
Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat);
copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
/* used for local constraints */
VECCOPY(pchanto->loc, pchanfrom->loc);
@ -1040,9 +1040,9 @@ void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose,
clear_workob(workob);
/* init workob */
Mat4CpyMat4(workob->obmat, ob->obmat);
Mat4CpyMat4(workob->parentinv, ob->parentinv);
Mat4CpyMat4(workob->constinv, ob->constinv);
copy_m4_m4(workob->obmat, ob->obmat);
copy_m4_m4(workob->parentinv, ob->parentinv);
copy_m4_m4(workob->constinv, ob->constinv);
workob->parent= ob->parent;
workob->track= ob->track;
@ -1109,7 +1109,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo
dstweight = 1.0F;
}
VecLerpf(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight);
interp_v3_v3v3(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight);
}
@ -1169,27 +1169,27 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
execute_action_ipo(achan, &pchan);
/* store offset that moves src to location of pchan */
VecSubf(vec, dpchan->loc, pchan.loc);
sub_v3_v3v3(vec, dpchan->loc, pchan.loc);
Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec);
mul_mat3_m4_v3(dpchan->bone->arm_mat, vec);
}
}
else {
/* store offset that moves src to location of dst */
VecSubf(vec, dpchan->loc, spchan->loc);
Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec);
sub_v3_v3v3(vec, dpchan->loc, spchan->loc);
mul_mat3_m4_v3(dpchan->bone->arm_mat, vec);
}
/* if blending, we only add with factor scrweight */
VecMulf(vec, srcweight);
mul_v3_fl(vec, srcweight);
VecAddf(dst->cyclic_offset, dst->cyclic_offset, vec);
add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, vec);
}
}
}
VecAddf(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset);
add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset);
}
/* added "sizecorr" here, to allow armatures to be scaled and still have striding.
@ -1249,14 +1249,14 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
if (pdistNewNormalized <= 1) {
// search for correction in positive path-direction
where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */
VecSubf(stride_offset, vec2, vec1);
sub_v3_v3v3(stride_offset, vec2, vec1);
}
else {
// we reached the end of the path, search backwards instead
where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */
VecSubf(stride_offset, vec1, vec2);
sub_v3_v3v3(stride_offset, vec1, vec2);
}
Mat4Mul3Vecfl(ob->obmat, stride_offset);
mul_mat3_m4_v3(ob->obmat, stride_offset);
return striptime;
}
}
@ -1295,10 +1295,10 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
}
if(foundvert) {
/* bring it into armature space */
VecSubf(min, max, min);
sub_v3_v3v3(min, max, min);
bone= get_named_bone(ob->data, strip->offs_bone); /* weak */
if(bone) {
Mat4Mul3Vecfl(bone->arm_mat, min);
mul_mat3_m4_v3(bone->arm_mat, min);
/* dominant motion, cyclic_offset was cleared in rest_pose */
if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) {
@ -1549,7 +1549,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
else if(blocktype==ID_AR) {
/* apply stride offset to object */
VecAddf(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset);
add_v3_v3v3(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset);
}
/* free */

@ -35,7 +35,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "DNA_listBase.h"
@ -135,11 +135,11 @@ void calc_curvepath(Object *ob)
for(a=0; a<tot; a++) {
fp++;
if(cycl && a==tot-1)
VecSubf(xyz, bevpfirst->vec, bevp->vec);
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
else
VecSubf(xyz, (bevp+1)->vec, bevp->vec);
sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec);
*fp= *(fp-1)+VecLength(xyz);
*fp= *(fp-1)+len_v3(xyz);
bevp++;
}
@ -177,11 +177,11 @@ void calc_curvepath(Object *ob)
fac1= fac2/fac1;
fac2= 1.0f-fac1;
VecLerpf(pp->vec, bevp->vec, bevpn->vec, fac2);
interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa;
pp->radius= fac1*bevp->radius + fac2*bevpn->radius;
QuatInterpol(pp->quat, bevp->quat, bevpn->quat, fac2);
NormalQuat(pp->quat);
interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
normalize_qt(pp->quat);
pp++;
}
@ -285,20 +285,20 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat,
* to more then one index in data which can give divide by zero error */
/*
totfac= data[0]+data[1];
if(totfac>0.000001) QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac);
if(totfac>0.000001) interp_qt_qtqt(q1, p0->quat, p1->quat, data[0] / totfac);
else QUATCOPY(q1, p1->quat);
NormalQuat(q1);
normalize_qt(q1);
totfac= data[2]+data[3];
if(totfac>0.000001) QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac);
if(totfac>0.000001) interp_qt_qtqt(q2, p2->quat, p3->quat, data[2] / totfac);
else QUATCOPY(q1, p3->quat);
NormalQuat(q2);
normalize_qt(q2);
totfac = data[0]+data[1]+data[2]+data[3];
if(totfac>0.000001) QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac);
if(totfac>0.000001) interp_qt_qtqt(quat, q1, q2, (data[0]+data[1]) / totfac);
else QUATCOPY(quat, q2);
NormalQuat(quat);
normalize_qt(quat);
*/
// XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases.
QUATCOPY(quat, p1->quat);
@ -318,8 +318,8 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
BLI_addtail(lb, dob);
dob->ob= ob;
Mat4CpyMat4(dob->mat, mat);
Mat4CpyMat4(dob->omat, ob->obmat);
copy_m4_m4(dob->mat, mat);
copy_m4_m4(dob->omat, ob->obmat);
dob->origlay= ob->lay;
dob->index= index;
dob->type= type;
@ -353,20 +353,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
/* Group Dupli Offset, should apply after everything else */
if (group->dupli_ofs[0] || group->dupli_ofs[1] || group->dupli_ofs[2]) {
Mat4CpyMat4(tmat, go->ob->obmat);
VecSubf(tmat[3], tmat[3], group->dupli_ofs);
Mat4MulMat4(mat, tmat, ob->obmat);
copy_m4_m4(tmat, go->ob->obmat);
sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
mul_m4_m4m4(mat, tmat, ob->obmat);
} else {
Mat4MulMat4(mat, go->ob->obmat, ob->obmat);
mul_m4_m4m4(mat, go->ob->obmat, ob->obmat);
}
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
dob->no_draw= (dob->origlay & group->layer)==0;
if(go->ob->transflag & OB_DUPLI) {
Mat4CpyMat4(dob->ob->obmat, dob->mat);
copy_m4_m4(dob->ob->obmat, dob->mat);
object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated);
Mat4CpyMat4(dob->ob->obmat, dob->omat);
copy_m4_m4(dob->ob->obmat, dob->omat);
}
}
}
@ -403,7 +403,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level,
#endif // XXX old animation system
where_is_object_time(scene, ob, (float)scene->r.cfra);
dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
Mat4CpyMat4(dob->omat, copyob.obmat);
copy_m4_m4(dob->omat, copyob.obmat);
}
}
@ -431,11 +431,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4];
VECCOPY(vec, co);
Mat4MulVecfl(vdd->pmat, vec);
VecSubf(vec, vec, vdd->pmat[3]);
VecAddf(vec, vec, vdd->obmat[3]);
mul_m4_v3(vdd->pmat, vec);
sub_v3_v3v3(vec, vec, vdd->pmat[3]);
add_v3_v3v3(vec, vec, vdd->obmat[3]);
Mat4CpyMat4(obmat, vdd->obmat);
copy_m4_m4(obmat, vdd->obmat);
VECCOPY(obmat[3], vec);
if(vdd->par->transflag & OB_DUPLIROT) {
@ -446,11 +446,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2];
}
vectoquat(vec, vdd->ob->trackflag, vdd->ob->upflag, q2);
vec_to_quat( q2,vec, vdd->ob->trackflag, vdd->ob->upflag);
QuatToMat3(q2, mat);
Mat4CpyMat4(tmat, obmat);
Mat4MulMat43(obmat, tmat, mat);
quat_to_mat3( mat,q2);
copy_m4_m4(tmat, obmat);
mul_m4_m4m3(obmat, tmat, mat);
}
dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated);
if(vdd->orco)
@ -458,10 +458,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
if(vdd->ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, vdd->ob->obmat);
Mat4CpyMat4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
copy_m4_m4(tmpmat, vdd->ob->obmat);
copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated);
Mat4CpyMat4(vdd->ob->obmat, tmpmat);
copy_m4_m4(vdd->ob->obmat, tmpmat);
}
}
@ -479,7 +479,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
float vec[3], no[3], pmat[4][4];
int lay, totvert, a, oblay;
Mat4CpyMat4(pmat, par->obmat);
copy_m4_m4(pmat, par->obmat);
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
@ -533,9 +533,9 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
if(par_space_mat)
Mat4MulMat4(vdd.obmat, ob->obmat, par_space_mat);
mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat);
else
Mat4CpyMat4(vdd.obmat, ob->obmat);
copy_m4_m4(vdd.obmat, ob->obmat);
vdd.id= id;
vdd.level= level;
@ -544,7 +544,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
vdd.ob= ob;
vdd.scene= scene;
vdd.par= par;
Mat4CpyMat4(vdd.pmat, pmat);
copy_m4_m4(vdd.pmat, pmat);
/* mballs have a different dupli handling */
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
@ -596,7 +596,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
copy_m4_m4(pmat, par->obmat);
em = me->edit_btmesh;
if(em) {
@ -661,11 +661,11 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
if(par_space_mat)
Mat4MulMat4(ob__obmat, ob->obmat, par_space_mat);
mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat);
else
Mat4CpyMat4(ob__obmat, ob->obmat);
copy_m4_m4(ob__obmat, ob->obmat);
Mat3CpyMat4(imat, ob->parentinv);
copy_m3_m4(imat, ob->parentinv);
/* mballs have a different dupli handling */
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
@ -683,34 +683,34 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
/* translation */
if(v4)
CalcCent4f(cent, v1, v2, v3, v4);
cent_quad_v3(cent, v1, v2, v3, v4);
else
CalcCent3f(cent, v1, v2, v3);
Mat4MulVecfl(pmat, cent);
cent_tri_v3(cent, v1, v2, v3);
mul_m4_v3(pmat, cent);
VecSubf(cent, cent, pmat[3]);
VecAddf(cent, cent, ob__obmat[3]);
sub_v3_v3v3(cent, cent, pmat[3]);
add_v3_v3v3(cent, cent, ob__obmat[3]);
Mat4CpyMat4(obmat, ob__obmat);
copy_m4_m4(obmat, ob__obmat);
VECCOPY(obmat[3], cent);
/* rotation */
triatoquat(v1, v2, v3, quat);
QuatToMat3(quat, mat);
tri_to_quat( quat,v1, v2, v3);
quat_to_mat3( mat,quat);
/* scale */
if(par->transflag & OB_DUPLIFACES_SCALE) {
float size= v4? AreaQ3Dfl(v1, v2, v3, v4): AreaT3Dfl(v1, v2, v3);
float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3);
size= sqrt(size) * par->dupfacesca;
Mat3MulFloat(mat[0], size);
mul_m3_fl(mat[0], size);
}
Mat3CpyMat3(mat3, mat);
Mat3MulMat3(mat, imat, mat3);
copy_m3_m3(mat3, mat);
mul_m3_m3m3(mat, imat, mat3);
Mat4CpyMat4(tmat, obmat);
Mat4MulMat43(obmat, tmat, mat);
copy_m4_m4(tmat, obmat);
mul_m4_m4m3(obmat, tmat, mat);
dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES, animated);
if(G.rendering) {
@ -741,10 +741,10 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
if(ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, ob->obmat);
Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */
copy_m4_m4(tmpmat, ob->obmat);
copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated);
Mat4CpyMat4(ob->obmat, tmpmat);
copy_m4_m4(ob->obmat, tmpmat);
}
}
@ -932,22 +932,22 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(psys_get_particle_state(&sim, a, &state, 0) == 0)
continue;
QuatToMat4(state.rot, pamat);
quat_to_mat4( pamat,state.rot);
VECCOPY(pamat[3], state.co);
pamat[3][3]= 1.0f;
}
if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
Mat4MulMat4(tmat, oblist[b]->obmat, pamat);
Mat4MulFloat3((float *)tmat, size*scale);
mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
mul_mat3_m4_fl((float *)tmat, size*scale);
if(par_space_mat)
Mat4MulMat4(mat, tmat, par_space_mat);
mul_m4_m4m4(mat, tmat, par_space_mat);
else
Mat4CpyMat4(mat, tmat);
copy_m4_m4(mat, tmat);
dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
Mat4CpyMat4(dob->omat, obcopylist[b].obmat);
copy_m4_m4(dob->omat, obcopylist[b].obmat);
if(G.rendering)
psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
@ -959,21 +959,21 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
VECCOPY(vec, obmat[3]);
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
Mat4CpyMat4(mat, pamat);
copy_m4_m4(mat, pamat);
Mat4MulMat4(tmat, obmat, mat);
Mat4MulFloat3((float *)tmat, size*scale);
mul_m4_m4m4(tmat, obmat, mat);
mul_mat3_m4_fl((float *)tmat, size*scale);
if(part->draw & PART_DRAW_GLOBAL_OB)
VECADD(tmat[3], tmat[3], vec);
if(par_space_mat)
Mat4MulMat4(mat, tmat, par_space_mat);
mul_m4_m4m4(mat, tmat, par_space_mat);
else
Mat4CpyMat4(mat, tmat);
copy_m4_m4(mat, tmat);
dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated);
Mat4CpyMat4(dob->omat, oldobmat);
copy_m4_m4(dob->omat, oldobmat);
if(G.rendering)
psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
@ -1034,7 +1034,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
copy_m4_m4(pmat, par->obmat);
/* in par the family name is stored, use this to find the other objects */
@ -1059,9 +1059,9 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
vec[1]= fsize*(ct->yof - yof);
vec[2]= 0.0;
Mat4MulVecfl(pmat, vec);
mul_m4_v3(pmat, vec);
Mat4CpyMat4(obmat, par->obmat);
copy_m4_m4(obmat, par->obmat);
VECCOPY(obmat[3], vec);
new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIVERTS, animated);
@ -1119,7 +1119,7 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
if (level==0) {
for(dob= duplilist->first; dob; dob= dob->next)
if(dob->type == OB_DUPLIGROUP)
Mat4CpyMat4(dob->ob->obmat, dob->mat);
copy_m4_m4(dob->ob->obmat, dob->mat);
}
}
}
@ -1140,7 +1140,7 @@ void free_object_duplilist(ListBase *lb)
for(dob= lb->first; dob; dob= dob->next) {
dob->ob->lay= dob->origlay;
Mat4CpyMat4(dob->ob->obmat, dob->omat);
copy_m4_m4(dob->ob->obmat, dob->omat);
}
BLI_freelistN(lb);

@ -36,7 +36,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "DNA_anim_types.h"

@ -34,7 +34,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_cellalloc.h"
@ -483,7 +483,7 @@ static void equalize_bezier(float *data, int desired)
pdist[0]= 0.0f;
for(a=0, fp= data; a<MAX_BBONE_SUBDIV; a++, fp+=4) {
QUATCOPY(temp[a], fp);
pdist[a+1]= pdist[a]+VecLenf(fp, fp+4);
pdist[a+1]= pdist[a]+len_v3v3(fp, fp+4);
}
/* do last point */
QUATCOPY(temp[a], fp);
@ -533,16 +533,16 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
if(!rest) {
/* check if we need to take non-uniform bone scaling into account */
scale[0]= VecLength(pchan->pose_mat[0]);
scale[1]= VecLength(pchan->pose_mat[1]);
scale[2]= VecLength(pchan->pose_mat[2]);
scale[0]= len_v3(pchan->pose_mat[0]);
scale[1]= len_v3(pchan->pose_mat[1]);
scale[2]= len_v3(pchan->pose_mat[2]);
if(fabs(scale[0] - scale[1]) > 1e-6f || fabs(scale[1] - scale[2]) > 1e-6f) {
Mat4One(scalemat);
unit_m4(scalemat);
scalemat[0][0]= scale[0];
scalemat[1][1]= scale[1];
scalemat[2][2]= scale[2];
Mat4Invert(iscalemat, scalemat);
invert_m4_m4(iscalemat, scalemat);
length *= scale[1];
doscale = 1;
@ -565,15 +565,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
last point = (0, length, 0) */
if(rest) {
Mat4Invert(imat, pchan->bone->arm_mat);
invert_m4_m4(imat, pchan->bone->arm_mat);
}
else if(doscale) {
Mat4CpyMat4(posemat, pchan->pose_mat);
Mat4Ortho(posemat);
Mat4Invert(imat, posemat);
copy_m4_m4(posemat, pchan->pose_mat);
normalize_m4(posemat);
invert_m4_m4(imat, posemat);
}
else
Mat4Invert(imat, pchan->pose_mat);
invert_m4_m4(imat, pchan->pose_mat);
if(prev) {
float difmat[4][4], result[3][3], imat3[3][3];
@ -583,7 +583,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
VECCOPY(h1, prev->bone->arm_head)
else
VECCOPY(h1, prev->pose_head)
Mat4MulVecfl(imat, h1);
mul_m4_v3(imat, h1);
if(prev->bone->segments>1) {
/* if previous bone is B-bone too, use average handle direction */
@ -591,21 +591,21 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
roll1= 0.0f;
}
Normalize(h1);
VecMulf(h1, -hlength1);
normalize_v3(h1);
mul_v3_fl(h1, -hlength1);
if(prev->bone->segments==1) {
/* find the previous roll to interpolate */
if(rest)
Mat4MulMat4(difmat, prev->bone->arm_mat, imat);
mul_m4_m4m4(difmat, prev->bone->arm_mat, imat);
else
Mat4MulMat4(difmat, prev->pose_mat, imat);
Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone
mul_m4_m4m4(difmat, prev->pose_mat, imat);
copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone
vec_roll_to_mat3(h1, 0.0f, mat3); // the result of vec_roll without roll
Mat3Inv(imat3, mat3);
Mat3MulMat3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll
invert_m3_m3(imat3, mat3);
mul_m3_m3m3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll
roll1= (float)atan2(mat3[2][0], mat3[2][2]);
}
@ -622,28 +622,28 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
VECCOPY(h2, next->bone->arm_tail)
else
VECCOPY(h2, next->pose_tail)
Mat4MulVecfl(imat, h2);
mul_m4_v3(imat, h2);
/* if next bone is B-bone too, use average handle direction */
if(next->bone->segments>1);
else h2[1]-= length;
Normalize(h2);
normalize_v3(h2);
/* find the next roll to interpolate as well */
if(rest)
Mat4MulMat4(difmat, next->bone->arm_mat, imat);
mul_m4_m4m4(difmat, next->bone->arm_mat, imat);
else
Mat4MulMat4(difmat, next->pose_mat, imat);
Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone
mul_m4_m4m4(difmat, next->pose_mat, imat);
copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone
vec_roll_to_mat3(h2, 0.0f, mat3); // the result of vec_roll without roll
Mat3Inv(imat3, mat3);
Mat3MulMat3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll
invert_m3_m3(imat3, mat3);
mul_m3_m3m3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll
roll2= (float)atan2(mat3[2][0], mat3[2][2]);
/* and only now negate handle */
VecMulf(h2, -hlength2);
mul_v3_fl(h2, -hlength2);
}
else {
h2[0]= 0.0f; h2[1]= -hlength2; h2[2]= 0.0f;
@ -663,15 +663,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
/* make transformation matrices for the segments for drawing */
for(a=0, fp= data[0]; a<bone->segments; a++, fp+=4) {
VecSubf(h1, fp+4, fp);
sub_v3_v3v3(h1, fp+4, fp);
vec_roll_to_mat3(h1, fp[3], mat3); // fp[3] is roll
Mat4CpyMat3(result_array[a].mat, mat3);
copy_m4_m3(result_array[a].mat, mat3);
VECCOPY(result_array[a].mat[3], fp);
if(doscale) {
/* correct for scaling when this matrix is used in scaled space */
Mat4MulSerie(result_array[a].mat, iscalemat, result_array[a].mat,
mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat,
scalemat, NULL, NULL, NULL, NULL, NULL);
}
}
@ -702,26 +702,26 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int re
/* first matrix is the inverse arm_mat, to bring points in local bone space
for finding out which segment it belongs to */
Mat4Invert(b_bone_mats[0].mat, bone->arm_mat);
invert_m4_m4(b_bone_mats[0].mat, bone->arm_mat);
/* then we make the b_bone_mats:
- first transform to local bone space
- translate over the curve to the bbone mat space
- transform with b_bone matrix
- transform back into global space */
Mat4One(tmat);
unit_m4(tmat);
for(a=0; a<bone->segments; a++) {
if(b_bone_rest)
Mat4Invert(tmat, b_bone_rest[a].mat);
invert_m4_m4(tmat, b_bone_rest[a].mat);
else
tmat[3][1] = -a*(bone->length/(float)bone->segments);
Mat4MulSerie(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat,
mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat,
b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL);
if(use_quaternion)
Mat4ToDQuat(bone->arm_mat, b_bone_mats[a+1].mat, &b_bone_dual_quats[a]);
mat4_to_dquat( &b_bone_dual_quats[a],bone->arm_mat, b_bone_mats[a+1].mat);
}
}
@ -744,13 +744,13 @@ static void b_bone_deform(bPoseChannel *pchan, Bone *bone, float *co, DualQuat *
CLAMP(a, 0, bone->segments-1);
if(dq) {
DQuatCpyDQuat(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]);
copy_dq_dq(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]);
}
else {
Mat4MulVecfl(b_bone[a+1].mat, co);
mul_m4_v3(b_bone[a+1].mat, co);
if(defmat)
Mat3CpyMat4(defmat, b_bone[a+1].mat);
copy_m3_m4(defmat, b_bone[a+1].mat);
}
}
@ -762,10 +762,10 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
float pdelta[3];
float hsqr, a, l, rad;
VecSubf (bdelta, b2, b1);
l = Normalize (bdelta);
sub_v3_v3v3(bdelta, b2, b1);
l = normalize_v3(bdelta);
VecSubf (pdelta, vec, b1);
sub_v3_v3v3(pdelta, vec, b1);
a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2];
hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2]));
@ -810,12 +810,12 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem
float wmat[3][3];
if(pchan->bone->segments>1)
Mat3CpyMat3(wmat, bbonemat);
copy_m3_m3(wmat, bbonemat);
else
Mat3CpyMat4(wmat, pchan->chan_mat);
copy_m3_m4(wmat, pchan->chan_mat);
Mat3MulFloat((float*)wmat, weight);
Mat3AddMat3(mat, mat, wmat);
mul_m3_fl((float*)wmat, weight);
add_m3_m3m3(mat, mat, wmat);
}
static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, float mat[][3], float *co)
@ -841,12 +841,12 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo
// applies on cop and bbonemat
b_bone_deform(pchan, bone, cop, NULL, (mat)?bbonemat:NULL);
else
Mat4MulVecfl(pchan->chan_mat, cop);
mul_m4_v3(pchan->chan_mat, cop);
// Make this a delta from the base position
VecSubf (cop, cop, co);
sub_v3_v3v3(cop, cop, co);
cop[0]*=fac; cop[1]*=fac; cop[2]*=fac;
VecAddf (vec, vec, cop);
add_v3_v3v3(vec, vec, cop);
if(mat)
pchan_deform_mat_add(pchan, fac, bbonemat, mat);
@ -854,10 +854,10 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo
else {
if(bone->segments>1) {
b_bone_deform(pchan, bone, cop, &bbonedq, NULL);
DQuatAddWeighted(dq, &bbonedq, fac);
add_weighted_dq_dq(dq, &bbonedq, fac);
}
else
DQuatAddWeighted(dq, pchan->dual_quat, fac);
add_weighted_dq_dq(dq, pchan->dual_quat, fac);
}
}
}
@ -880,7 +880,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua
// applies on cop and bbonemat
b_bone_deform(pchan, pchan->bone, cop, NULL, (mat)?bbonemat:NULL);
else
Mat4MulVecfl(pchan->chan_mat, cop);
mul_m4_v3(pchan->chan_mat, cop);
vec[0]+=(cop[0]-co[0])*weight;
vec[1]+=(cop[1]-co[1])*weight;
@ -892,10 +892,10 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua
else {
if(pchan->bone->segments>1) {
b_bone_deform(pchan, pchan->bone, cop, &bbonedq, NULL);
DQuatAddWeighted(dq, &bbonedq, weight);
add_weighted_dq_dq(dq, &bbonedq, weight);
}
else
DQuatAddWeighted(dq, pchan->dual_quat, weight);
add_weighted_dq_dq(dq, pchan->dual_quat, weight);
}
(*contrib)+=weight;
@ -924,10 +924,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
if(arm->edbo) return;
Mat4Invert(obinv, target->obmat);
Mat4CpyMat4(premat, target->obmat);
Mat4MulMat4(postmat, armOb->obmat, obinv);
Mat4Invert(premat, postmat);
invert_m4_m4(obinv, target->obmat);
copy_m4_m4(premat, target->obmat);
mul_m4_m4m4(postmat, armOb->obmat, obinv);
invert_m4_m4(premat, postmat);
/* bone defmats are already in the channels, chan_mat */
@ -945,7 +945,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
if(use_quaternion) {
pchan->dual_quat= &dualquats[totchan++];
Mat4ToDQuat(pchan->bone->arm_mat, pchan->chan_mat, pchan->dual_quat);
mat4_to_dquat( pchan->dual_quat,pchan->bone->arm_mat, pchan->chan_mat);
}
}
}
@ -1014,7 +1014,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
vec= sumvec;
if(defMats) {
Mat3Clr((float*)summat);
zero_m3((float*)summat);
smat = summat;
}
}
@ -1051,7 +1051,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
co= prevCos?prevCos[i]:vertexCos[i];
/* Apply the object's matrix */
Mat4MulVecfl(premat, co);
mul_m4_v3(premat, co);
if(use_dverts && dvert && dvert->totweight) { // use weight groups ?
int deformed = 0;
@ -1097,42 +1097,42 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
/* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
if(contrib > 0.0001f) {
if(use_quaternion) {
DQuatNormalize(dq, contrib);
normalize_dq(dq, contrib);
if(armature_weight != 1.0f) {
VECCOPY(dco, co);
DQuatMulVecfl(dq, dco, (defMats)? summat: NULL);
VecSubf(dco, dco, co);
VecMulf(dco, armature_weight);
VecAddf(co, co, dco);
mul_v3m3_dq( dco, (defMats)? summat: NULL,dq);
sub_v3_v3v3(dco, dco, co);
mul_v3_fl(dco, armature_weight);
add_v3_v3v3(co, co, dco);
}
else
DQuatMulVecfl(dq, co, (defMats)? summat: NULL);
mul_v3m3_dq( co, (defMats)? summat: NULL,dq);
smat = summat;
}
else {
VecMulf(vec, armature_weight/contrib);
VecAddf(co, vec, co);
mul_v3_fl(vec, armature_weight/contrib);
add_v3_v3v3(co, vec, co);
}
if(defMats) {
float pre[3][3], post[3][3], tmpmat[3][3];
Mat3CpyMat4(pre, premat);
Mat3CpyMat4(post, postmat);
Mat3CpyMat3(tmpmat, defMats[i]);
copy_m3_m4(pre, premat);
copy_m3_m4(post, postmat);
copy_m3_m3(tmpmat, defMats[i]);
if(!use_quaternion) /* quaternion already is scale corrected */
Mat3MulFloat((float*)smat, armature_weight/contrib);
mul_m3_fl((float*)smat, armature_weight/contrib);
Mat3MulSerie(defMats[i], tmpmat, pre, smat, post,
mul_serie_m3(defMats[i], tmpmat, pre, smat, post,
NULL, NULL, NULL, NULL);
}
}
/* always, check above code */
Mat4MulVecfl(postmat, co);
mul_m4_v3(postmat, co);
/* interpolate with previous modifier position using weight group */
@ -1166,7 +1166,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed)
{
Mat4CpyMat4(M_accumulatedMatrix, bone->arm_mat);
copy_m4_m4(M_accumulatedMatrix, bone->arm_mat);
}
/* **************** Space to Space API ****************** */
@ -1180,10 +1180,10 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4])
if (ob==NULL) return;
/* get inverse of (armature) object's matrix */
Mat4Invert(obmat, ob->obmat);
invert_m4_m4(obmat, ob->obmat);
/* multiply given matrix by object's-inverse to find pose-space matrix */
Mat4MulMat4(outmat, obmat, inmat);
mul_m4_m4m4(outmat, obmat, inmat);
}
/* Convert Wolrd-Space Location to Pose-Space Location
@ -1196,7 +1196,7 @@ void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc)
float nLocMat[4][4];
/* build matrix for location */
Mat4One(xLocMat);
unit_m4(xLocMat);
VECCOPY(xLocMat[3], inloc);
/* get bone-space cursor matrix and extract location */
@ -1218,24 +1218,24 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
/* get the inverse matrix of the pchan's transforms */
if (pchan->rotmode)
LocEulSizeToMat4(pc_trans, pchan->loc, pchan->eul, pchan->size);
loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size);
else
LocQuatSizeToMat4(pc_trans, pchan->loc, pchan->quat, pchan->size);
Mat4Invert(inv_trans, pc_trans);
loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size);
invert_m4_m4(inv_trans, pc_trans);
/* Remove the pchan's transforms from it's pose_mat.
* This should leave behind the effects of restpose +
* parenting + constraints
*/
Mat4MulMat4(pc_posemat, inv_trans, pchan->pose_mat);
mul_m4_m4m4(pc_posemat, inv_trans, pchan->pose_mat);
/* get the inverse of the leftovers so that we can remove
* that component from the supplied matrix
*/
Mat4Invert(inv_posemat, pc_posemat);
invert_m4_m4(inv_posemat, pc_posemat);
/* get the new matrix */
Mat4MulMat4(outmat, inmat, inv_posemat);
mul_m4_m4m4(outmat, inmat, inv_posemat);
}
/* Convert Pose-Space Location to Bone-Space Location
@ -1248,7 +1248,7 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc)
float nLocMat[4][4];
/* build matrix for location */
Mat4One(xLocMat);
unit_m4(xLocMat);
VECCOPY(xLocMat[3], inloc);
/* get bone-space cursor matrix and extract location */
@ -1264,8 +1264,8 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float
{
float imat[4][4];
Mat4Invert(imat, arm_mat);
Mat4MulMat4(delta_mat, pose_mat, imat);
invert_m4_m4(imat, arm_mat);
mul_m4_m4m4(delta_mat, pose_mat, imat);
}
/* **************** Rotation Mode Conversions ****************************** */
@ -1281,33 +1281,33 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa
if (newMode > 0) { /* to euler */
if (oldMode == ROT_MODE_AXISANGLE) {
/* axis-angle to euler */
AxisAngleToEulO(axis, *angle, eul, newMode);
axis_angle_to_eulO( eul, newMode,axis, *angle);
}
else if (oldMode == ROT_MODE_QUAT) {
/* quat to euler */
QuatToEulO(quat, eul, newMode);
quat_to_eulO( eul, newMode,quat);
}
/* else { no conversion needed } */
}
else if (newMode == ROT_MODE_QUAT) { /* to quat */
if (oldMode == ROT_MODE_AXISANGLE) {
/* axis angle to quat */
AxisAngleToQuat(quat, axis, *angle);
axis_angle_to_quat(quat, axis, *angle);
}
else if (oldMode > 0) {
/* euler to quat */
EulOToQuat(eul, oldMode, quat);
eulO_to_quat( quat,eul, oldMode);
}
/* else { no conversion needed } */
}
else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */
if (oldMode > 0) {
/* euler to axis angle */
EulOToAxisAngle(eul, oldMode, axis, angle);
eulO_to_axis_angle( axis, angle,eul, oldMode);
}
else if (oldMode == ROT_MODE_QUAT) {
/* quat to axis angle */
QuatToAxisAngle(quat, axis, angle);
quat_to_axis_angle( axis, angle,quat);
}
/* when converting to axis-angle, we need a special exception for the case when there is no axis */
@ -1342,14 +1342,14 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa
void mat3_to_vec_roll(float mat[][3], float *vec, float *roll)
{
if (vec)
VecCopyf(vec, mat[1]);
copy_v3_v3(vec, mat[1]);
if (roll) {
float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
vec_roll_to_mat3(mat[1], 0.0f, vecmat);
Mat3Inv(vecmatinv, vecmat);
Mat3MulMat3(rollmat, vecmatinv, mat);
invert_m3_m3(vecmatinv, vecmat);
mul_m3_m3m3(rollmat, vecmatinv, mat);
*roll= (float)atan2(rollmat[2][0], rollmat[2][2]);
}
@ -1364,26 +1364,26 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
float rMatrix[3][3], bMatrix[3][3];
VECCOPY (nor, vec);
Normalize (nor);
normalize_v3(nor);
/* Find Axis & Amount for bone matrix*/
Crossf (axis,target,nor);
cross_v3_v3v3(axis,target,nor);
if (Inpf(axis,axis) > 0.0000000000001) {
if (dot_v3v3(axis,axis) > 0.0000000000001) {
/* if nor is *not* a multiple of target ... */
Normalize (axis);
normalize_v3(axis);
theta= NormalizedVecAngle2(target, nor);
theta= angle_normalized_v3v3(target, nor);
/* Make Bone matrix*/
VecRotToMat3(axis, theta, bMatrix);
vec_rot_to_mat3( bMatrix,axis, theta);
}
else {
/* if nor is a multiple of target ... */
float updown;
/* point same direction, or opposite? */
updown = ( Inpf (target,nor) > 0 ) ? 1.0f : -1.0f;
updown = ( dot_v3v3(target,nor) > 0 ) ? 1.0f : -1.0f;
/* I think this should work ... */
bMatrix[0][0]=updown; bMatrix[0][1]=0.0; bMatrix[0][2]=0.0;
@ -1392,10 +1392,10 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
}
/* Make Roll matrix*/
VecRotToMat3(nor, roll, rMatrix);
vec_rot_to_mat3( rMatrix,nor, roll);
/* Combine and output result*/
Mat3MulMat3 (mat, rMatrix, bMatrix);
mul_m3_m3m3(mat, rMatrix, bMatrix);
}
@ -1406,10 +1406,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
float vec[3];
/* Bone Space */
VecSubf (vec, bone->tail, bone->head);
sub_v3_v3v3(vec, bone->tail, bone->head);
vec_roll_to_mat3(vec, bone->roll, bone->bone_mat);
bone->length= VecLenf(bone->head, bone->tail);
bone->length= len_v3v3(bone->head, bone->tail);
/* this is called on old file reading too... */
if(bone->xwidth==0.0) {
@ -1422,7 +1422,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b)
/* bone transform itself */
Mat4CpyMat3(offs_bone, bone->bone_mat);
copy_m4_m3(offs_bone, bone->bone_mat);
/* The bone's root offset (is in the parent's coordinate system) */
VECCOPY(offs_bone[3], bone->head);
@ -1431,10 +1431,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
offs_bone[3][1]+= prevbone->length;
/* Compose the matrix for this bone */
Mat4MulMat4(bone->arm_mat, offs_bone, prevbone->arm_mat);
mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat);
}
else {
Mat4CpyMat3(bone->arm_mat, bone->bone_mat);
copy_m4_m3(bone->arm_mat, bone->bone_mat);
VECCOPY(bone->arm_mat[3], bone->head);
}
@ -1442,8 +1442,8 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
VECCOPY(bone->arm_head, bone->arm_mat[3]);
/* tail is in current local coord system */
VECCOPY(vec, bone->arm_mat[1]);
VecMulf(vec, bone->length);
VecAddf(bone->arm_tail, bone->arm_head, vec);
mul_v3_fl(vec, bone->length);
add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
/* and the kiddies */
prevbone= bone;
@ -1825,7 +1825,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* step 1a: get xyz positions for the tail endpoint of the bone */
if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) {
/* convert the position to pose-space, then store it */
Mat4MulVecfl(ob->imat, vec);
mul_m4_v3(ob->imat, vec);
VECCOPY(poseTail, vec);
/* set the new radius */
@ -1835,7 +1835,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* step 1b: get xyz positions for the head endpoint of the bone */
if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) {
/* store the position, and convert it to pose space */
Mat4MulVecfl(ob->imat, vec);
mul_m4_v3(ob->imat, vec);
VECCOPY(poseHead, vec);
/* set the new radius (it should be the average value) */
@ -1846,8 +1846,8 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
* - splineVec: the vector direction that the spline applies on the bone
* - scaleFac: the factor that the bone length is scaled by to get the desired amount
*/
VecSubf(splineVec, poseTail, poseHead);
scaleFac= VecLength(splineVec) / pchan->bone->length;
sub_v3_v3v3(splineVec, poseTail, poseHead);
scaleFac= len_v3(splineVec) / pchan->bone->length;
/* step 3: compute the shortest rotation needed to map from the bone rotation to the current axis
* - this uses the same method as is used for the Damped Track Constraint (see the code there for details)
@ -1862,45 +1862,45 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
VECCOPY(rmat[0], pchan->pose_mat[0]);
VECCOPY(rmat[1], pchan->pose_mat[1]);
VECCOPY(rmat[2], pchan->pose_mat[2]);
Mat3Ortho(rmat);
normalize_m3(rmat);
/* also, normalise the orientation imposed by the bone, now that we've extracted the scale factor */
Normalize(splineVec);
normalize_v3(splineVec);
/* calculate smallest axis-angle rotation necessary for getting from the
* current orientation of the bone, to the spline-imposed direction
*/
Crossf(raxis, rmat[1], splineVec);
cross_v3_v3v3(raxis, rmat[1], splineVec);
rangle= Inpf(rmat[1], splineVec);
rangle= dot_v3v3(rmat[1], splineVec);
rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) );
/* construct rotation matrix from the axis-angle rotation found above
* - this call takes care to make sure that the axis provided is a unit vector first
*/
AxisAngleToMat3(raxis, rangle, dmat);
axis_angle_to_mat3( dmat,raxis, rangle);
/* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates,
* while still maintaining roll control from the existing bone animation
*/
Mat3MulMat3(tmat, dmat, rmat); // m1, m3, m2
Mat3Ortho(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */
Mat4CpyMat3(poseMat, tmat);
mul_m3_m3m3(tmat, dmat, rmat); // m1, m3, m2
normalize_m3(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */
copy_m4_m3(poseMat, tmat);
}
/* step 4: set the scaling factors for the axes */
// TODO: include a no-scale option?
{
/* only multiply the y-axis by the scaling factor to get nice volume-preservation */
VecMulf(poseMat[1], scaleFac);
mul_v3_fl(poseMat[1], scaleFac);
/* set the scaling factors of the x and z axes from... */
switch (ikData->xzScaleMode) {
case CONSTRAINT_SPLINEIK_XZS_RADIUS:
{
/* radius of curve */
VecMulf(poseMat[0], radius);
VecMulf(poseMat[2], radius);
mul_v3_fl(poseMat[0], radius);
mul_v3_fl(poseMat[2], radius);
}
break;
case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:
@ -1909,11 +1909,11 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
float scale;
/* x-axis scale */
scale= VecLength(pchan->pose_mat[0]);
VecMulf(poseMat[0], scale);
scale= len_v3(pchan->pose_mat[0]);
mul_v3_fl(poseMat[0], scale);
/* z-axis scale */
scale= VecLength(pchan->pose_mat[2]);
VecMulf(poseMat[2], scale);
scale= len_v3(pchan->pose_mat[2]);
mul_v3_fl(poseMat[2], scale);
}
break;
}
@ -1923,7 +1923,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
VECCOPY(poseMat[3], poseHead);
/* finally, store the new transform */
Mat4CpyMat4(pchan->pose_mat, poseMat);
copy_m4_m4(pchan->pose_mat, poseMat);
VECCOPY(pchan->pose_head, poseHead);
VECCOPY(pchan->pose_tail, poseTail);
@ -1975,26 +1975,26 @@ void chan_calc_mat(bPoseChannel *chan)
float tmat[3][3];
/* get scaling matrix */
SizeToMat3(chan->size, smat);
size_to_mat3( smat,chan->size);
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (chan->rotmode > 0) {
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
EulOToMat3(chan->eul, chan->rotmode, rmat);
eulO_to_mat3( rmat,chan->eul, chan->rotmode);
}
else if (chan->rotmode == ROT_MODE_AXISANGLE) {
/* axis-angle - not really that great for 3D-changing orientations */
AxisAngleToMat3(chan->rotAxis, chan->rotAngle, rmat);
axis_angle_to_mat3( rmat,chan->rotAxis, chan->rotAngle);
}
else {
/* quats are normalised before use to eliminate scaling issues */
NormalQuat(chan->quat); // TODO: do this with local vars only!
QuatToMat3(chan->quat, rmat);
normalize_qt(chan->quat); // TODO: do this with local vars only!
quat_to_mat3( rmat,chan->quat);
}
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
Mat3MulMat3(tmat, rmat, smat);
Mat4CpyMat3(chan->chan_mat, tmat);
mul_m3_m3m3(tmat, rmat, smat);
copy_m4_m3(chan->chan_mat, tmat);
/* prevent action channels breaking chains */
/* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */
@ -2058,8 +2058,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
float mat4[4][4], mat3[3][3];
curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
Mat4CpyMat4(mat4, pchan->pose_mat);
Mat4MulMat34(pchan->pose_mat, mat3, mat4);
copy_m4_m4(mat4, pchan->pose_mat);
mul_m4_m3m4(pchan->pose_mat, mat3, mat4);
}
}
@ -2076,8 +2076,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
/* make a copy of starting conditions */
VECCOPY(loc, pchan->pose_mat[3]);
Mat4ToEul(pchan->pose_mat, eul);
Mat4ToSize(pchan->pose_mat, size);
mat4_to_eul( eul,pchan->pose_mat);
mat4_to_size( size,pchan->pose_mat);
VECCOPY(eulo, eul);
VECCOPY(sizeo, size);
@ -2087,14 +2087,14 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs;
VecAddf(size, size, nor);
add_v3_v3v3(size, size, nor);
if (sizeo[0] != 0)
VecMulf(pchan->pose_mat[0], size[0] / sizeo[0]);
mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]);
if (sizeo[1] != 0)
VecMulf(pchan->pose_mat[1], size[1] / sizeo[1]);
mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]);
if (sizeo[2] != 0)
VecMulf(pchan->pose_mat[2], size[2] / sizeo[2]);
mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]);
}
if (amod->channels & 2) {
/* for rotation */
@ -2103,10 +2103,10 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs;
compatible_eul(nor, eulo);
VecAddf(eul, eul, nor);
add_v3_v3v3(eul, eul, nor);
compatible_eul(eul, eulo);
LocEulSizeToMat4(pchan->pose_mat, loc, eul, size);
loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size);
}
if (amod->channels & 1) {
/* for location */
@ -2114,7 +2114,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs;
VecAddf(pchan->pose_mat[3], loc, nor);
add_v3_v3v3(pchan->pose_mat[3], loc, nor);
}
}
}
@ -2149,7 +2149,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b)
/* bone transform itself */
Mat4CpyMat3(offs_bone, bone->bone_mat);
copy_m4_m3(offs_bone, bone->bone_mat);
/* The bone's root offset (is in the parent's coordinate system) */
VECCOPY(offs_bone[3], bone->head);
@ -2162,39 +2162,39 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
float tmat[4][4];
/* the rotation of the parent restposition */
Mat4CpyMat4(tmat, parbone->arm_mat);
copy_m4_m4(tmat, parbone->arm_mat);
/* the location of actual parent transform */
VECCOPY(tmat[3], offs_bone[3]);
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
Mat4MulVecfl(parchan->pose_mat, tmat[3]);
mul_m4_v3(parchan->pose_mat, tmat[3]);
Mat4MulSerie(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
}
else if(bone->flag & BONE_NO_SCALE) {
float orthmat[4][4];
/* get the official transform, but we only use the vector from it (optimize...) */
Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
VECCOPY(vec, pchan->pose_mat[3]);
/* do this again, but with an ortho-parent matrix */
Mat4CpyMat4(orthmat, parchan->pose_mat);
Mat4Ortho(orthmat);
Mat4MulSerie(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
copy_m4_m4(orthmat, parchan->pose_mat);
normalize_m4(orthmat);
mul_serie_m4(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
/* copy correct transform */
VECCOPY(pchan->pose_mat[3], vec);
}
else
Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
}
else {
Mat4MulMat4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
/* only rootbones get the cyclic offset (unless user doesn't want that) */
if ((bone->flag & BONE_NO_CYCLICOFFSET) == 0)
VecAddf(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset);
add_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset);
}
/* do NLA strip modifiers - i.e. curve follow */
@ -2230,8 +2230,8 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
VECCOPY(pchan->pose_head, pchan->pose_mat[3]);
/* calculate tail */
VECCOPY(vec, pchan->pose_mat[1]);
VecMulf(vec, bone->length);
VecAddf(pchan->pose_tail, pchan->pose_head, vec);
mul_v3_fl(vec, bone->length);
add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec);
}
/* This only reads anim data from channels, and writes to channels */
@ -2259,14 +2259,14 @@ void where_is_pose (Scene *scene, Object *ob)
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
bone= pchan->bone;
if(bone) {
Mat4CpyMat4(pchan->pose_mat, bone->arm_mat);
copy_m4_m4(pchan->pose_mat, bone->arm_mat);
VECCOPY(pchan->pose_head, bone->arm_head);
VECCOPY(pchan->pose_tail, bone->arm_tail);
}
}
}
else {
Mat4Invert(ob->imat, ob->obmat); // imat is needed
invert_m4_m4(ob->imat, ob->obmat); // imat is needed
/* 1. clear flags */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
@ -2304,8 +2304,8 @@ void where_is_pose (Scene *scene, Object *ob)
/* calculating deform matrices */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone) {
Mat4Invert(imat, pchan->bone->arm_mat);
Mat4MulMat4(pchan->chan_mat, imat, pchan->pose_mat);
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat);
}
}
}

@ -43,7 +43,7 @@
#include "DNA_listBase.h"
#include "BLI_rand.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
@ -135,10 +135,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
/* estimate future location of target */
get_effector_data(eff, &efd, &epoint, 1);
VecMulf(efd.vel, efd.distance / (val->max_speed * bbd->timestep));
VecAddf(efd.loc, efd.loc, efd.vel);
VecSubf(efd.vec_to_point, pa->prev_state.co, efd.loc);
efd.distance = VecLength(efd.vec_to_point);
mul_v3_fl(efd.vel, efd.distance / (val->max_speed * bbd->timestep));
add_v3_v3v3(efd.loc, efd.loc, efd.vel);
sub_v3_v3v3(efd.vec_to_point, pa->prev_state.co, efd.loc);
efd.distance = len_v3(efd.vec_to_point);
}
if(rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) {
@ -152,17 +152,17 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
priority > 2.0f * gabr->fear_factor) {
/* detach from surface and try to fly away from danger */
VECCOPY(efd.vec_to_point, bpa->gravity);
VecMulf(efd.vec_to_point, -1.0f);
mul_v3_fl(efd.vec_to_point, -1.0f);
}
VECCOPY(bbd->wanted_co, efd.vec_to_point);
VecMulf(bbd->wanted_co, mul);
mul_v3_fl(bbd->wanted_co, mul);
bbd->wanted_speed = val->max_speed * priority;
/* with goals factor is approach velocity factor */
if(rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) {
float len2 = 2.0f*VecLength(pa->prev_state.vel);
float len2 = 2.0f*len_v3(pa->prev_state.vel);
surface *= pa->size * boids->height;
@ -198,12 +198,12 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
float radius = val->personal_space * pa->size, ray_dir[3];
VECCOPY(col.co1, pa->prev_state.co);
VecAddf(col.co2, pa->prev_state.co, pa->prev_state.vel);
VecSubf(ray_dir, col.co2, col.co1);
VecMulf(ray_dir, acbr->look_ahead);
add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel);
sub_v3_v3v3(ray_dir, col.co2, col.co1);
mul_v3_fl(ray_dir, acbr->look_ahead);
col.t = 0.0f;
hit.index = -1;
hit.dist = col.ray_len = VecLength(ray_dir);
hit.dist = col.ray_len = len_v3(ray_dir);
/* find out closest deflector object */
for(coll = bbd->sim->colliders->first; coll; coll=coll->next) {
@ -224,9 +224,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
VECCOPY(bbd->wanted_co, col.nor);
VecMulf(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size);
mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size);
bbd->wanted_speed = sqrt(t) * VecLength(pa->prev_state.vel);
bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel);
return 1;
}
@ -235,39 +235,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
//check boids in own system
if(acbr->options & BRULE_ACOLL_WITH_BOIDS)
{
neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
if(neighbors > 1) for(n=1; n<neighbors; n++) {
VECCOPY(co1, pa->prev_state.co);
VECCOPY(vel1, pa->prev_state.vel);
VECCOPY(co2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.co);
VECCOPY(vel2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.vel);
VecSubf(loc, co1, co2);
sub_v3_v3v3(loc, co1, co2);
VecSubf(vec, vel1, vel2);
sub_v3_v3v3(vec, vel1, vel2);
inp = Inpf(vec,vec);
inp = dot_v3v3(vec,vec);
/* velocities not parallel */
if(inp != 0.0f) {
t = -Inpf(loc, vec)/inp;
t = -dot_v3v3(loc, vec)/inp;
/* cpa is not too far in the future so investigate further */
if(t > 0.0f && t < t_min) {
VECADDFAC(co1, co1, vel1, t);
VECADDFAC(co2, co2, vel2, t);
VecSubf(vec, co2, co1);
sub_v3_v3v3(vec, co2, co1);
len = Normalize(vec);
len = normalize_v3(vec);
/* distance of cpa is close enough */
if(len < 2.0f * val->personal_space * pa->size) {
t_min = t;
VecMulf(vec, VecLength(vel1));
VecMulf(vec, (2.0f - t)/2.0f);
VecSubf(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = VecLength(bbd->wanted_co);
mul_v3_fl(vec, len_v3(vel1));
mul_v3_fl(vec, (2.0f - t)/2.0f);
sub_v3_v3v3(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
}
@ -281,39 +281,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
if(epsys) {
neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
if(neighbors > 0) for(n=0; n<neighbors; n++) {
VECCOPY(co1, pa->prev_state.co);
VECCOPY(vel1, pa->prev_state.vel);
VECCOPY(co2, (epsys->particles + ptn[n].index)->prev_state.co);
VECCOPY(vel2, (epsys->particles + ptn[n].index)->prev_state.vel);
VecSubf(loc, co1, co2);
sub_v3_v3v3(loc, co1, co2);
VecSubf(vec, vel1, vel2);
sub_v3_v3v3(vec, vel1, vel2);
inp = Inpf(vec,vec);
inp = dot_v3v3(vec,vec);
/* velocities not parallel */
if(inp != 0.0f) {
t = -Inpf(loc, vec)/inp;
t = -dot_v3v3(loc, vec)/inp;
/* cpa is not too far in the future so investigate further */
if(t > 0.0f && t < t_min) {
VECADDFAC(co1, co1, vel1, t);
VECADDFAC(co2, co2, vel2, t);
VecSubf(vec, co2, co1);
sub_v3_v3v3(vec, co2, co1);
len = Normalize(vec);
len = normalize_v3(vec);
/* distance of cpa is close enough */
if(len < 2.0f * val->personal_space * pa->size) {
t_min = t;
VecMulf(vec, VecLength(vel1));
VecMulf(vec, (2.0f - t)/2.0f);
VecSubf(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = VecLength(bbd->wanted_co);
mul_v3_fl(vec, len_v3(vel1));
mul_v3_fl(vec, (2.0f - t)/2.0f);
sub_v3_v3v3(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
}
@ -340,9 +340,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa
int ret = 0;
if(neighbors > 1 && ptn[1].dist!=0.0f) {
VecSubf(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co);
VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
bbd->wanted_speed = val->max_speed;
len = ptn[1].dist;
ret = 1;
@ -357,9 +357,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa
neighbors = BLI_kdtree_range_search(epsys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn);
if(neighbors > 0 && ptn[0].dist < len) {
VecSubf(vec, pa->prev_state.co, ptn[0].co);
VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
bbd->wanted_speed = val->max_speed;
len = ptn[0].dist;
ret = 1;
@ -380,19 +380,19 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
if(neighbors > 1) {
for(n=1; n<neighbors; n++) {
VecAddf(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co);
VecAddf(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
add_v3_v3v3(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co);
add_v3_v3v3(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
}
VecMulf(loc, 1.0f/((float)neighbors - 1.0f));
VecMulf(vec, 1.0f/((float)neighbors - 1.0f));
mul_v3_fl(loc, 1.0f/((float)neighbors - 1.0f));
mul_v3_fl(vec, 1.0f/((float)neighbors - 1.0f));
VecSubf(loc, loc, pa->prev_state.co);
VecSubf(vec, vec, pa->prev_state.vel);
sub_v3_v3v3(loc, loc, pa->prev_state.co);
sub_v3_v3v3(vec, vec, pa->prev_state.vel);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
VecAddf(bbd->wanted_co, bbd->wanted_co, loc);
bbd->wanted_speed = VecLength(bbd->wanted_co);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, loc);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@ -410,16 +410,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
float vec2[3], t;
/* first check we're not blocking the leader*/
VecSubf(vec, flbr->loc, flbr->oloc);
VecMulf(vec, 1.0f/bbd->timestep);
sub_v3_v3v3(vec, flbr->loc, flbr->oloc);
mul_v3_fl(vec, 1.0f/bbd->timestep);
VecSubf(loc, pa->prev_state.co, flbr->oloc);
sub_v3_v3v3(loc, pa->prev_state.co, flbr->oloc);
mul = Inpf(vec, vec);
mul = dot_v3v3(vec, vec);
/* leader is not moving */
if(mul < 0.01) {
len = VecLength(loc);
len = len_v3(loc);
/* too close to leader */
if(len < 2.0f * val->personal_space * pa->size) {
VECCOPY(bbd->wanted_co, loc);
@ -428,16 +428,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
}
else {
t = Inpf(loc, vec)/mul;
t = dot_v3v3(loc, vec)/mul;
/* possible blocking of leader in near future */
if(t > 0.0f && t < 3.0f) {
VECCOPY(vec2, vec);
VecMulf(vec2, t);
mul_v3_fl(vec2, t);
VecSubf(vec2, loc, vec2);
sub_v3_v3v3(vec2, loc, vec2);
len = VecLength(vec2);
len = len_v3(vec2);
if(len < 2.0f * val->personal_space * pa->size) {
VECCOPY(bbd->wanted_co, vec2);
@ -454,15 +454,15 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
else {
VECCOPY(loc, flbr->oloc);
VecSubf(vec, flbr->loc, flbr->oloc);
VecMulf(vec, 1.0/bbd->timestep);
sub_v3_v3v3(vec, flbr->loc, flbr->oloc);
mul_v3_fl(vec, 1.0/bbd->timestep);
}
/* fac is seconds behind leader */
VECADDFAC(loc, loc, vec, -flbr->distance);
VecSubf(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = VecLength(bbd->wanted_co);
sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@ -473,13 +473,13 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
for(i = 0; i< bbd->sim->psys->totpart; i+=n){
VECCOPY(vec, bbd->sim->psys->particles[i].prev_state.vel);
VecSubf(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
mul = Inpf(vec, vec);
mul = dot_v3v3(vec, vec);
/* leader is not moving */
if(mul < 0.01) {
len = VecLength(loc);
len = len_v3(loc);
/* too close to leader */
if(len < 2.0f * val->personal_space * pa->size) {
VECCOPY(bbd->wanted_co, loc);
@ -488,16 +488,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
}
else {
t = Inpf(loc, vec)/mul;
t = dot_v3v3(loc, vec)/mul;
/* possible blocking of leader in near future */
if(t > 0.0f && t < t_min) {
VECCOPY(vec2, vec);
VecMulf(vec2, t);
mul_v3_fl(vec2, t);
VecSubf(vec2, loc, vec2);
sub_v3_v3v3(vec2, loc, vec2);
len = VecLength(vec2);
len = len_v3(vec2);
if(len < 2.0f * val->personal_space * pa->size) {
t_min = t;
@ -524,8 +524,8 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
/* fac is seconds behind leader */
VECADDFAC(loc, loc, vec, -flbr->distance);
VecSubf(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = VecLength(bbd->wanted_co);
sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@ -544,30 +544,30 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
bpa->wander[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
Normalize(bpa->wander);
normalize_v3(bpa->wander);
VECCOPY(vec, bpa->wander);
QuatMulVecf(pa->prev_state.rot, vec);
mul_qt_v3(pa->prev_state.rot, vec);
VECCOPY(bbd->wanted_co, pa->prev_state.ave);
VecMulf(bbd->wanted_co, 1.1f);
mul_v3_fl(bbd->wanted_co, 1.1f);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
/* leveling */
if(asbr->level > 0.0f) {
Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
VecMulf(vec, asbr->level);
VecSubf(bbd->wanted_co, bbd->wanted_co, vec);
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
mul_v3_fl(vec, asbr->level);
sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
}
}
else {
VECCOPY(bbd->wanted_co, pa->prev_state.ave);
/* may happen at birth */
if(Inp2f(bbd->wanted_co,bbd->wanted_co)==0.0f) {
if(dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) {
bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand());
bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand());
bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand());
@ -575,9 +575,9 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
/* leveling */
if(asbr->level > 0.0f) {
Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
VecMulf(vec, asbr->level);
VecSubf(bbd->wanted_co, bbd->wanted_co, vec);
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
mul_v3_fl(vec, asbr->level);
sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
}
}
@ -641,20 +641,20 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
}
/* decide action if enemy presence found */
if(e_strength > 0.0f) {
VecSubf(bbd->wanted_co, closest_enemy, pa->prev_state.co);
sub_v3_v3v3(bbd->wanted_co, closest_enemy, pa->prev_state.co);
/* attack if in range */
if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) {
float damage = BLI_frand();
float enemy_dir[3] = {bbd->wanted_co[0],bbd->wanted_co[1],bbd->wanted_co[2]};
Normalize(enemy_dir);
normalize_v3(enemy_dir);
/* fight mode */
bbd->wanted_speed = 0.0f;
/* must face enemy to fight */
if(Inpf(pa->prev_state.ave, enemy_dir)>0.5f) {
if(dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) {
bpa = enemy_pa->boid;
bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy);
}
@ -669,7 +669,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
/* decide to flee */
if(closest_dist < fbr->flee_distance * fbr->distance) {
VecMulf(bbd->wanted_co, -1.0f);
mul_v3_fl(bbd->wanted_co, -1.0f);
bbd->wanted_speed = val->max_speed;
}
else { /* wait for better odds */
@ -735,7 +735,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
/* take surface velocity into account */
closest_point_on_surface(surmd, pa->state.co, x, NULL, v);
VecAddf(x, x, v);
add_v3_v3v3(x, x, v);
/* get actual position on surface */
closest_point_on_surface(surmd, x, ground_co, ground_nor, NULL);
@ -754,12 +754,12 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
VECCOPY(col.co1, pa->state.co);
VECCOPY(col.co2, pa->state.co);
VecAddf(col.co1, col.co1, zvec);
VecSubf(col.co2, col.co2, zvec);
VecSubf(ray_dir, col.co2, col.co1);
add_v3_v3v3(col.co1, col.co1, zvec);
sub_v3_v3v3(col.co2, col.co2, zvec);
sub_v3_v3v3(ray_dir, col.co2, col.co1);
col.t = 0.0f;
hit.index = -1;
hit.dist = col.ray_len = VecLength(ray_dir);
hit.dist = col.ray_len = len_v3(ray_dir);
/* find out upmost deflector object */
for(coll = bbd->sim->colliders->first; coll; coll = coll->next){
@ -772,9 +772,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
/* then use that object */
if(hit.index>=0) {
t = hit.dist/col.ray_len;
VecLerpf(ground_co, col.co1, col.co2, t);
interp_v3_v3v3(ground_co, col.co1, col.co2, t);
VECCOPY(ground_nor, col.nor);
Normalize(ground_nor);
normalize_v3(ground_nor);
return col.hit_ob;
}
else {
@ -829,23 +829,23 @@ static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co,
/* gather apparent gravity */
VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
/* raise boid it's size from surface */
VecMulf(nor, pa->size * boids->height);
VecAddf(pa->state.co, surface_co, nor);
mul_v3_fl(nor, pa->size * boids->height);
add_v3_v3v3(pa->state.co, surface_co, nor);
/* remove normal component from velocity */
Projf(vel, pa->state.vel, surface_nor);
VecSubf(pa->state.vel, pa->state.vel, vel);
project_v3_v3v3(vel, pa->state.vel, surface_nor);
sub_v3_v3v3(pa->state.vel, pa->state.vel, vel);
}
static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_nor)
{
float vec[3];
VecSubf(vec, boid_co, goal_co);
sub_v3_v3v3(vec, boid_co, goal_co);
return Inpf(vec, goal_nor);
return dot_v3v3(vec, goal_nor);
}
/* wanted_co is relative to boid location */
static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness)
@ -859,7 +859,7 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val,
if(boid_rules[rule->type](rule, bbd, val, pa)==0)
return 0;
if(fuzziness < 0.0f || VecLenCompare(bbd->wanted_co, pa->prev_state.vel, fuzziness * VecLength(pa->prev_state.vel))==0)
if(fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0)
return 1;
else
return 0;
@ -943,7 +943,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
int n = 0;
for(rule = state->rules.first; rule; rule=rule->next) {
if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
VecAddf(wanted_co, wanted_co, bbd->wanted_co);
add_v3_v3v3(wanted_co, wanted_co, bbd->wanted_co);
wanted_speed += bbd->wanted_speed;
n++;
bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f;
@ -951,7 +951,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
if(n > 1) {
VecMulf(wanted_co, 1.0f/(float)n);
mul_v3_fl(wanted_co, 1.0f/(float)n);
wanted_speed /= (float)n;
}
@ -971,12 +971,12 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
float cvel[3], dir[3];
VECCOPY(dir, pa->prev_state.ave);
Normalize2(dir);
normalize_v2(dir);
VECCOPY(cvel, bbd->wanted_co);
Normalize2(cvel);
normalize_v2(cvel);
if(Inp2f(cvel, dir) > 0.95 / mul)
if(dot_v2v2(cvel, dir) > 0.95 / mul)
bpa->data.mode = eBoidMode_Liftoff;
}
else if(val.jump_speed > 0.0f) {
@ -990,20 +990,20 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
float len;
VECCOPY(dir, pa->prev_state.ave);
Normalize2(dir);
normalize_v2(dir);
VECCOPY(cvel, bbd->wanted_co);
Normalize2(cvel);
normalize_v2(cvel);
len = Vec2Length(pa->prev_state.vel);
len = len_v2(pa->prev_state.vel);
/* first of all, are we going in a suitable direction? */
/* or at a suitably slow speed */
if(Inp2f(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
if(dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
/* try to reach goal at highest point of the parabolic path */
cur_v = Vec2Length(pa->prev_state.vel);
cur_v = len_v2(pa->prev_state.vel);
z_v = sasqrt(-2.0f * bbd->part->acc[2] * bbd->wanted_co[2]);
ground_v = Vec2Length(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]);
ground_v = len_v2(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]);
len = sasqrt((ground_v-cur_v)*(ground_v-cur_v) + z_v*z_v);
@ -1014,11 +1014,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
VECCOPY(jump_v, dir);
jump_v[2] = z_v;
VecMulf(jump_v, ground_v);
mul_v3_fl(jump_v, ground_v);
Normalize(jump_v);
VecMulf(jump_v, len);
Vec2Addf(jump_v, jump_v, pa->prev_state.vel);
normalize_v3(jump_v);
mul_v3_fl(jump_v, len);
add_v2_v2v2(jump_v, jump_v, pa->prev_state.vel);
}
}
}
@ -1103,7 +1103,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
VECCOPY(old_dir, pa->prev_state.ave);
VECCOPY(wanted_dir, bbd->wanted_co);
new_speed = Normalize(wanted_dir);
new_speed = normalize_v3(wanted_dir);
/* first check if we have valid direction we want to go towards */
if(new_speed == 0.0f) {
@ -1111,39 +1111,39 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
}
else {
float old_dir2[2], wanted_dir2[2], nor[3], angle;
Vec2Copyf(old_dir2, old_dir);
Normalize2(old_dir2);
Vec2Copyf(wanted_dir2, wanted_dir);
Normalize2(wanted_dir2);
copy_v2_v2(old_dir2, old_dir);
normalize_v2(old_dir2);
copy_v2_v2(wanted_dir2, wanted_dir);
normalize_v2(wanted_dir2);
/* choose random direction to turn if wanted velocity */
/* is directly behind regardless of z-coordinate */
if(Inp2f(old_dir2, wanted_dir2) < -0.99f) {
if(dot_v2v2(old_dir2, wanted_dir2) < -0.99f) {
wanted_dir[0] = 2.0f*(0.5f - BLI_frand());
wanted_dir[1] = 2.0f*(0.5f - BLI_frand());
wanted_dir[2] = 2.0f*(0.5f - BLI_frand());
Normalize(wanted_dir);
normalize_v3(wanted_dir);
}
/* constrain direction with maximum angular velocity */
angle = saacos(Inpf(old_dir, wanted_dir));
angle = saacos(dot_v3v3(old_dir, wanted_dir));
angle = MIN2(angle, val.max_ave);
Crossf(nor, old_dir, wanted_dir);
VecRotToQuat(nor, angle, q);
cross_v3_v3v3(nor, old_dir, wanted_dir);
axis_angle_to_quat( q,nor, angle);
VECCOPY(new_dir, old_dir);
QuatMulVecf(q, new_dir);
Normalize(new_dir);
mul_qt_v3(q, new_dir);
normalize_v3(new_dir);
/* save direction in case resulting velocity too small */
VecRotToQuat(nor, angle*dtime, q);
axis_angle_to_quat( q,nor, angle*dtime);
VECCOPY(pa->state.ave, old_dir);
QuatMulVecf(q, pa->state.ave);
Normalize(pa->state.ave);
mul_qt_v3(q, pa->state.ave);
normalize_v3(pa->state.ave);
}
/* constrain speed with maximum acceleration */
old_speed = VecLength(pa->prev_state.vel);
old_speed = len_v3(pa->prev_state.vel);
if(bbd->wanted_speed < old_speed)
new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc);
@ -1152,11 +1152,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* combine direction and speed */
VECCOPY(new_vel, new_dir);
VecMulf(new_vel, new_speed);
mul_v3_fl(new_vel, new_speed);
/* maintain minimum flying velocity if not landing */
if(level >= landing_level) {
float len2 = Inp2f(new_vel,new_vel);
float len2 = dot_v2v2(new_vel,new_vel);
float root;
len2 = MAX2(len2, val.min_speed*val.min_speed);
@ -1164,20 +1164,20 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
new_vel[2] = new_vel[2] < 0.0f ? -root : root;
Normalize2(new_vel);
Vec2Mulf(new_vel, sasqrt(len2));
normalize_v2(new_vel);
mul_v2_fl(new_vel, sasqrt(len2));
}
/* finally constrain speed to max speed */
new_speed = Normalize(new_vel);
VecMulf(new_vel, MIN2(new_speed, val.max_speed));
new_speed = normalize_v3(new_vel);
mul_v3_fl(new_vel, MIN2(new_speed, val.max_speed));
/* get acceleration from difference of velocities */
VecSubf(acc, new_vel, pa->prev_state.vel);
sub_v3_v3v3(acc, new_vel, pa->prev_state.vel);
/* break acceleration to components */
Projf(tan_acc, acc, pa->prev_state.ave);
VecSubf(nor_acc, acc, tan_acc);
project_v3_v3v3(tan_acc, acc, pa->prev_state.ave);
sub_v3_v3v3(nor_acc, acc, tan_acc);
}
/* account for effectors */
@ -1185,32 +1185,32 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL);
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
float length = Normalize(force);
float length = normalize_v3(force);
length = MAX2(0.0f, length - boids->land_stick_force);
VecMulf(force, length);
mul_v3_fl(force, length);
}
VecAddf(acc, acc, force);
add_v3_v3v3(acc, acc, force);
/* store smoothed acceleration for nice banking etc. */
VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime);
VecMulf(bpa->data.acc, 1.0f / (1.0f + dtime));
mul_v3_fl(bpa->data.acc, 1.0f / (1.0f + dtime));
/* integrate new location & velocity */
/* by regarding the acceleration as a force at this stage we*/
/* can get better control allthough it's a bit unphysical */
VecMulf(acc, 1.0f/pa_mass);
mul_v3_fl(acc, 1.0f/pa_mass);
VECCOPY(dvec, acc);
VecMulf(dvec, dtime*dtime*0.5f);
mul_v3_fl(dvec, dtime*dtime*0.5f);
VECCOPY(bvec, pa->prev_state.vel);
VecMulf(bvec, dtime);
VecAddf(dvec, dvec, bvec);
VecAddf(pa->state.co, pa->state.co, dvec);
mul_v3_fl(bvec, dtime);
add_v3_v3v3(dvec, dvec, bvec);
add_v3_v3v3(pa->state.co, pa->state.co, dvec);
VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime);
@ -1224,9 +1224,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f};
/* don't take forward acceleration into account (better banking) */
if(Inpf(bpa->data.acc, pa->state.vel) > 0.0f) {
Projf(dvec, bpa->data.acc, pa->state.vel);
VecSubf(dvec, bpa->data.acc, dvec);
if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel);
sub_v3_v3v3(dvec, bpa->data.acc, dvec);
}
else {
VECCOPY(dvec, bpa->data.acc);
@ -1234,7 +1234,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* gather apparent gravity */
VECADDFAC(bpa->gravity, grav, dvec, -boids->banking);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
/* stick boid on goal when close enough */
if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
@ -1257,7 +1257,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* gather apparent gravity */
VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
if(boids->options & BOID_ALLOW_LAND) {
/* stick boid on goal when close enough */
@ -1289,15 +1289,15 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
///* gather apparent gravity to r_ve */
//VECADDFAC(pa->r_ve, pa->r_ve, ground_nor, -1.0);
//Normalize(pa->r_ve);
//normalize_v3(pa->r_ve);
///* raise boid it's size from surface */
//VecMulf(nor, pa->size * boids->height);
//VecAddf(pa->state.co, ground_co, nor);
//mul_v3_fl(nor, pa->size * boids->height);
//add_v3_v3v3(pa->state.co, ground_co, nor);
///* remove normal component from velocity */
//Projf(v, pa->state.vel, ground_nor);
//VecSubf(pa->state.vel, pa->state.vel, v);
//project_v3_v3v3(v, pa->state.vel, ground_nor);
//sub_v3_v3v3(pa->state.vel, pa->state.vel, v);
break;
}
case eBoidMode_OnLand:
@ -1323,19 +1323,19 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* Don't take gravity's strength in to account, */
/* otherwise amount of banking is hard to control. */
VECCOPY(grav, ground_nor);
VecMulf(grav, -1.0f);
mul_v3_fl(grav, -1.0f);
Projf(dvec, bpa->data.acc, pa->state.vel);
VecSubf(dvec, bpa->data.acc, dvec);
project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel);
sub_v3_v3v3(dvec, bpa->data.acc, dvec);
/* gather apparent gravity */
VECADDFAC(bpa->gravity, grav, dvec, -boids->banking);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
}
else {
/* gather negative surface normal */
VECADDFAC(bpa->gravity, bpa->gravity, ground_nor, -1.0f);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
}
break;
}
@ -1343,36 +1343,36 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* save direction to state.ave unless the boid is falling */
/* (boids can't effect their direction when falling) */
if(bpa->data.mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) {
if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) {
VECCOPY(pa->state.ave, pa->state.vel);
Normalize(pa->state.ave);
normalize_v3(pa->state.ave);
}
/* apply damping */
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
VecMulf(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
mul_v3_fl(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
/* calculate rotation matrix based on forward & down vectors */
if(bpa->data.mode == eBoidMode_InAir) {
VECCOPY(mat[0], pa->state.ave);
Projf(dvec, bpa->gravity, pa->state.ave);
VecSubf(mat[2], bpa->gravity, dvec);
Normalize(mat[2]);
project_v3_v3v3(dvec, bpa->gravity, pa->state.ave);
sub_v3_v3v3(mat[2], bpa->gravity, dvec);
normalize_v3(mat[2]);
}
else {
Projf(dvec, pa->state.ave, bpa->gravity);
VecSubf(mat[0], pa->state.ave, dvec);
Normalize(mat[0]);
project_v3_v3v3(dvec, pa->state.ave, bpa->gravity);
sub_v3_v3v3(mat[0], pa->state.ave, dvec);
normalize_v3(mat[0]);
VECCOPY(mat[2], bpa->gravity);
}
VecMulf(mat[2], -1.0f);
Crossf(mat[1], mat[2], mat[0]);
mul_v3_fl(mat[2], -1.0f);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
/* apply rotation */
Mat3ToQuat_is_ok(mat, q);
QuatCopy(pa->state.rot, q);
mat3_to_quat_is_ok( q,mat);
copy_qt_qt(pa->state.rot, q);
}
BoidRule *boid_new_rule(int type)

@ -33,7 +33,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
@ -104,7 +104,7 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert)
float global_pos[3];
/* boolean happens in global space, transform both with obmat */
VecMat4MulVecfl(
mul_v3_m4v3(
global_pos,
iterator->ob->obmat,
verts[iterator->pos].co
@ -327,11 +327,11 @@ static void InterpCSGFace(
for (j = 0; j < nr; j++) {
// get coordinate into the space of the original mesh
if (mapmat)
VecMat4MulVecfl(obco, mapmat, co[j]);
mul_v3_m4v3(obco, mapmat, co[j]);
else
VecCopyf(obco, co[j]);
copy_v3_v3(obco, co[j]);
InterpWeightsQ3Dfl(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco, w[j]);
interp_weights_face_v3( w[j],orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco);
}
CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index);
@ -375,7 +375,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
// we have to map the vertex coordinates back in the coordinate frame
// of the resulting object, since it was computed in world space
VecMat4MulVecfl(mvert->co, parinv, csgvert.position);
mul_v3_m4v3(mvert->co, parinv, csgvert.position);
}
// a hash table to remap materials to indices
@ -480,9 +480,9 @@ DerivedMesh *NewBooleanDerivedMesh_intern(
// we map the final object back into ob's local coordinate space. For this
// we need to compute the inverse transform from global to ob (inv_mat),
// and the transform from ob to ob_select for use in interpolation (map_mat)
Mat4Invert(inv_mat, ob->obmat);
Mat4MulMat4(map_mat, ob_select->obmat, inv_mat);
Mat4Invert(inv_mat, ob_select->obmat);
invert_m4_m4(inv_mat, ob->obmat);
mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat);
invert_m4_m4(inv_mat, ob_select->obmat);
{
// interface with the boolean module:

@ -47,7 +47,7 @@
#include "BKE_library.h"
#include "BKE_material.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
/**
* Implementation of boolean ops mesh interface.
@ -151,7 +151,7 @@ CSG_AddMeshToBlender(
if (mesh == NULL) return 0;
if (mesh->base == NULL) return 0;
Mat4Invert(inv_mat,mesh->base->object->obmat);
invert_m4_m4(inv_mat,mesh->base->object->obmat);
// Create a new blender mesh object - using 'base' as
// a template for the new object.

@ -42,7 +42,7 @@
#include "RNA_access.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_rand.h"
@ -845,8 +845,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
/* setup starting time, direction vector and accumulated time */
starttime= painter->accumtime;
Vec2Subf(dmousepos, pos, painter->lastmousepos);
len= Normalize2(dmousepos);
sub_v2_v2v2(dmousepos, pos, painter->lastmousepos);
len= normalize_v2(dmousepos);
painter->accumtime += curtime - painter->lasttime;
/* do paint op over unpainted time distance */
@ -880,8 +880,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
/* setup starting distance, direction vector and accumulated distance */
startdistance= painter->accumdistance;
Vec2Subf(dmousepos, pos, painter->lastmousepos);
len= Normalize2(dmousepos);
sub_v2_v2v2(dmousepos, pos, painter->lastmousepos);
len= normalize_v2(dmousepos);
painter->accumdistance += len;
/* do paint op over unpainted distance */

@ -45,7 +45,7 @@
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_linklist.h"
#include "MEM_guardedalloc.h"
@ -55,7 +55,7 @@ static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, con
{
float dist;
if(RayIntersectsTriangle((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL))
if(isect_ray_tri_v3((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL))
return dist;
return FLT_MAX;
@ -68,10 +68,10 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con
float p1[3];
float plane_normal[3], hit_point[3];
CalcNormFloat((float*)v0, (float*)v1, (float*)v2, plane_normal);
normal_tri_v3( plane_normal,(float*)v0, (float*)v1, (float*)v2);
VECADDFAC( p1, ray->origin, ray->direction, m_dist);
if(SweepingSphereIntersectsTriangleUV((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point))
if(isect_sweeping_sphere_tri_v3((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point))
{
return idist * m_dist;
}
@ -384,9 +384,9 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const
float w[3], x[3], y[3], z[3];
VECCOPY(w, v0);
VECCOPY(x, e0);
VecMulf(x, S);
mul_v3_fl(x, S);
VECCOPY(y, e1);
VecMulf(y, T);
mul_v3_fl(y, T);
VECADD(z, w, x);
VECADD(z, z, y);
//VECSUB(d, p, z);
@ -430,7 +430,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co,
nearest->index = index;
nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp);
CalcNormFloat(t0, t1, t2, nearest->no);
normal_tri_v3( nearest->no,t0, t1, t2);
}
t1 = t2;
@ -469,7 +469,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
hit->dist = dist;
VECADDFAC(hit->co, ray->origin, ray->direction, dist);
CalcNormFloat(t0, t1, t2, hit->no);
normal_tri_v3( hit->no,t0, t1, t2);
}
t1 = t2;
@ -492,16 +492,16 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co,
t0 = vert[ edge->v1 ].co;
t1 = vert[ edge->v2 ].co;
PclosestVL3Dfl(nearest_tmp, co, t0, t1);
dist = VecLenf(nearest_tmp, co);
closest_to_line_segment_v3(nearest_tmp, co, t0, t1);
dist = len_v3v3(nearest_tmp, co);
if(dist < nearest->dist)
{
nearest->index = index;
nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp);
VecSubf(nearest->no, t0, t1);
Normalize(nearest->no);
sub_v3_v3v3(nearest->no, t0, t1);
normalize_v3(nearest->no);
}
}

@ -48,7 +48,7 @@
#include "BLI_editVert.h"
#include "BLI_scanfill.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_editVert.h"
@ -417,9 +417,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *a
/* TODO make this better (cache facenormals as layer?) */
float nor[3];
if(mface->v4) {
CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co, nor);
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
} else {
CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, nor);
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
}
glNormal3fv(nor);
}
@ -588,9 +588,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
else {
float nor[3];
if(mf->v4) {
CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co, nor);
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
} else {
CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, nor);
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
}
glNormal3fv(nor);
}
@ -759,9 +759,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
else {
float nor[3];
if(mf->v4) {
CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co, nor);
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
} else {
CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, nor);
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
}
glNormal3fv(nor);
}
@ -931,9 +931,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
/* TODO ideally a normal layer should always be available */
float nor[3];
if(mface->v4) {
CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co, nor);
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
} else {
CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, nor);
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
}
glNormal3fv(nor);
}
@ -1275,17 +1275,17 @@ static void cdDM_foreachMappedFaceCenter(
ml = &cddm->mloop[mf->loopstart];
cent[0] = cent[1] = cent[2] = 0.0f;
for (j=0; j<mf->totloop; j++, ml++) {
VecAddf(cent, cent, mv[ml->v].co);
add_v3_v3v3(cent, cent, mv[ml->v].co);
}
VecMulf(cent, 1.0f / (float)j);
mul_v3_fl(cent, 1.0f / (float)j);
ml = &cddm->mloop[mf->loopstart];
if (j > 3) {
CalcNormFloat4(mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co, mv[(ml+3)->v].co, no);
normal_quad_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co, mv[(ml+3)->v].co);
} else {
CalcNormFloat(mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co, no);
normal_tri_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co);
}
func(userData, orig, cent, no);
@ -2041,9 +2041,9 @@ void CDDM_calc_normals(DerivedMesh *dm)
for (i=0; i<dm->numVertData; i++, mv++) {
float *no = vert_nors[i];
if (Normalize(no) == 0.0) {
if (normalize_v3(no) == 0.0) {
VECCOPY(no, mv->co);
if (Normalize(no) == 0.0) {
if (normalize_v3(no) == 0.0) {
no[0] = 0.0f;
no[1] = 0.0f;
no[2] = 1.0f;
@ -2460,7 +2460,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig,
mvert = CustomData_get_layer(&orig->vertData, CD_MVERT);
mrdm->orco = MEM_callocN(sizeof(float) * 3 * orig->getNumVerts(orig), "multires orco");
for(i = 0; i < orig->getNumVerts(orig); ++i)
VecCopyf(mrdm->orco[i], mvert[i].co);
copy_v3_v3(mrdm->orco[i], mvert[i].co);
}
else
DM_init(dm, numVerts, numEdges, numFaces, numLoops, numPolys);

@ -404,7 +404,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
/* Get the current position. */
VECCOPY(verts->xconst, mvert[i].co);
Mat4MulVecfl(ob->obmat, verts->xconst);
mul_m4_v3(ob->obmat, verts->xconst);
}
effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights);
@ -724,7 +724,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *
if (clmd->clothObject) {
/* inverse matrix is not uptodate... */
Mat4Invert (ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
mvert = CDDM_get_verts(dm);
numverts = dm->getNumVerts(dm);
@ -732,7 +732,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *
for (i = 0; i < numverts; i++)
{
VECCOPY (mvert[i].co, cloth->verts[i].x);
Mat4MulVecfl (ob->imat, mvert[i].co); /* cloth is in global coords */
mul_m4_v3(ob->imat, mvert[i].co); /* cloth is in global coords */
}
}
}
@ -868,7 +868,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
if(first)
{
VECCOPY ( verts->x, mvert[i].co );
Mat4MulVecfl ( ob->obmat, verts->x );
mul_m4_v3( ob->obmat, verts->x );
}
/* no GUI interface yet */
@ -885,7 +885,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
VECCOPY ( verts->xconst, verts->x );
VECCOPY ( verts->txold, verts->x );
VECCOPY ( verts->tx, verts->x );
VecMulf ( verts->v, 0.0f );
mul_v3_fl( verts->v, 0.0f );
verts->impulse_count = 0;
VECCOPY ( verts->impulse, tnull );

@ -529,7 +529,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
// calculate tangential velocity
VECCOPY ( temp, collpair->normal );
VecMulf ( temp, magrelVel );
mul_v3_fl( temp, magrelVel );
VECSUB ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
@ -539,7 +539,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
Normalize ( vrel_t_pre );
normalize_v3( vrel_t_pre );
impulse = magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); // 2.0 *
VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse );
@ -681,7 +681,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap
if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) )
{
VECCOPY ( collpair->normal, collpair->vector );
Normalize ( collpair->normal );
normalize_v3( collpair->normal );
collpair->distance = distance;
collpair->flag = 0;
@ -778,7 +778,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
// calculate tangential velocity
VECCOPY ( temp, collpair->normal );
VecMulf ( temp, magrelVel );
mul_v3_fl( temp, magrelVel );
VECSUB ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
@ -788,7 +788,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
Normalize ( vrel_t_pre );
normalize_v3( vrel_t_pre );
impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 );
VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse );
@ -853,15 +853,15 @@ static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,flo
// printf("l1: %f, l1: %f, l2: %f, l2: %f\n", line1[0], line1[1], line2[0], line2[1]);
Crossf(out_normal, line1, line2);
cross_v3_v3v3(out_normal, line1, line2);
length = Normalize(out_normal);
length = normalize_v3(out_normal);
if (length <= FLT_EPSILON)
{ // lines are collinear
VECSUB(out_normal, np2, np1);
Normalize(out_normal);
normalize_v3(out_normal);
}
}
@ -901,7 +901,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
VECSUB(line1, np12, np11);
VECSUB(line2, np22, np21);
Crossf(cross, line1, line2);
cross_v3_v3v3(cross, line1, line2);
length = INPR(cross, cross);
if (length < FLT_EPSILON)
@ -912,7 +912,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
*out_a1 = 0;
calculateEENormal(np11, np12, np21, np22, out_normal);
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(temp2, temp, np21);
VECADD(temp2, temp2, np11);
return INPR(temp2, temp2);
@ -928,7 +928,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return (np22 - (np11 + (np12 - np11) * out_a1)).lengthSquared();
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(temp2, temp, np11);
VECSUB(temp2, np22, temp2);
return INPR(temp2, temp2);
@ -943,7 +943,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return (np21 - (np11 + (np12 - np11) * out_a1)).lengthSquared();
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(temp2, temp, np11);
VECSUB(temp2, np21, temp2);
return INPR(temp2, temp2);
@ -991,12 +991,12 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// p1= np11 + (np12 - np11) * out_a1;
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(p1, np11, temp);
// p2 = np21 + (np22 - np21) * out_a2;
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(p2, np21, temp);
calculateEENormal(np11, np12, np21, np22, out_normal);
@ -1022,7 +1022,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// p1 = np11 + (np12 - np11) * out_a1;
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(p1, np11, temp);
*out_a2 = projectPointOntoLine(p1, np21, np22);
@ -1032,7 +1032,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return (p1 - (np21 + (np22 - np21) * out_a2)).lengthSquared();
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(temp, temp, np21);
VECSUB(temp, p1, temp);
return INPR(temp, temp);
@ -1044,7 +1044,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// p2 = np21 + (np22 - np21) * out_a2;
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(p2, np21, temp);
*out_a1 = projectPointOntoLine(p2, np11, np12);
@ -1054,7 +1054,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return ((np11 + (np12 - np11) * out_a1) - p2).lengthSquared();
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(temp, temp, np11);
VECSUB(temp, temp, p2);
return INPR(temp, temp);
@ -1217,16 +1217,16 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
float desiredVn;
VECCOPY(vrel_1_to_2, verts1[edgecollpair.p11].tv);
VecMulf(vrel_1_to_2, 1.0 - a);
mul_v3_fl(vrel_1_to_2, 1.0 - a);
VECCOPY(temp, verts1[edgecollpair.p12].tv);
VecMulf(temp, a);
mul_v3_fl(temp, a);
VECADD(vrel_1_to_2, vrel_1_to_2, temp);
VECCOPY(temp, verts1[edgecollpair.p21].tv);
VecMulf(temp, 1.0 - b);
mul_v3_fl(temp, 1.0 - b);
VECCOPY(temp2, verts1[edgecollpair.p22].tv);
VecMulf(temp2, b);
mul_v3_fl(temp2, b);
VECADD(temp, temp, temp2);
VECSUB(vrel_1_to_2, vrel_1_to_2, temp);
@ -1237,7 +1237,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
if(out_normalVelocity < 0.0)
{
out_normalVelocity*= -1.0;
VecNegf(out_normal);
negate_v3(out_normal);
}
*/
/* Inelastic repulsion impulse. */
@ -1707,7 +1707,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
continue;
}
length = Normalize ( temp );
length = normalize_v3( temp );
if ( length < mindistance )
{
@ -1715,17 +1715,17 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
{
VecMulf ( temp, -correction );
mul_v3_fl( temp, -correction );
VECADD ( verts[j].tx, verts[j].tx, temp );
}
else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
{
VecMulf ( temp, correction );
mul_v3_fl( temp, correction );
VECADD ( verts[i].tx, verts[i].tx, temp );
}
else
{
VecMulf ( temp, -correction*0.5 );
mul_v3_fl( temp, -correction*0.5 );
VECADD ( verts[j].tx, verts[j].tx, temp );
VECSUB ( verts[i].tx, verts[i].tx, temp );

@ -52,7 +52,7 @@
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_threads.h"
#include "IMB_imbuf.h"
@ -462,35 +462,35 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
if(bezt[0].h2==HD_AUTO) {
hlen= VecLenf(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 */
VECCOPY(vec, bezt[1].vec[0]);
if(vec[0] < bezt[0].vec[1][0])
vec[0]= bezt[0].vec[1][0];
VecSubf(vec, vec, bezt[0].vec[1]);
nlen= VecLength(vec);
sub_v3_v3v3(vec, vec, bezt[0].vec[1]);
nlen= len_v3(vec);
if(nlen>FLT_EPSILON) {
VecMulf(vec, hlen/nlen);
VecAddf(bezt[0].vec[2], vec, bezt[0].vec[1]);
VecSubf(bezt[0].vec[0], bezt[0].vec[1], vec);
mul_v3_fl(vec, hlen/nlen);
add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]);
sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec);
}
}
a= cuma->totpoint-1;
if(bezt[a].h2==HD_AUTO) {
hlen= VecLenf(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 */
VECCOPY(vec, bezt[a-1].vec[2]);
if(vec[0] > bezt[a].vec[1][0])
vec[0]= bezt[a].vec[1][0];
VecSubf(vec, vec, bezt[a].vec[1]);
nlen= VecLength(vec);
sub_v3_v3v3(vec, vec, bezt[a].vec[1]);
nlen= len_v3(vec);
if(nlen>FLT_EPSILON) {
VecMulf(vec, hlen/nlen);
VecAddf(bezt[a].vec[0], vec, bezt[a].vec[1]);
VecSubf(bezt[a].vec[2], bezt[a].vec[1], vec);
mul_v3_fl(vec, hlen/nlen);
add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]);
sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec);
}
}
}

File diff suppressed because it is too large Load Diff

@ -40,7 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_object_types.h"
#include "DNA_curve_types.h"
@ -992,7 +992,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float
for(i=0; i<3; i++) {
p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i];
}
Normalize(p);
normalize_v3(p);
p = (float *)(((char *)p)+stride);
}
}
@ -1598,7 +1598,7 @@ static void bevel_list_calc_bisect(BevList *bl)
nr= bl->nr;
while(nr--) {
/* totally simple */
VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
bevp0= bevp1;
bevp1= bevp2;
@ -1616,8 +1616,8 @@ static void bevel_list_flip_tangents(BevList *bl)
nr= bl->nr;
while(nr--) {
if(RAD2DEG(VecAngle2(bevp0->tan, bevp1->tan)) > 90)
VecNegf(bevp1->tan);
if(RAD2DEG(angle_v2v2(bevp0->tan, bevp1->tan)) > 90)
negate_v3(bevp1->tan);
bevp0= bevp1;
bevp1= bevp2;
@ -1637,9 +1637,9 @@ static void bevel_list_apply_tilt(BevList *bl)
nr= bl->nr;
while(nr--) {
AxisAngleToQuat(q, bevp1->dir, bevp1->alfa);
QuatMul(bevp1->quat, q, bevp1->quat);
NormalQuat(bevp1->quat);
axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
normalize_qt(bevp1->quat);
bevp0= bevp1;
bevp1= bevp2;
@ -1683,18 +1683,18 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
while(nr--) {
/* interpolate quats */
float zaxis[3] = {0,0,1}, cross[3], q2[4];
QuatInterpol(q, bevp0_quat, bevp2->quat, 0.5);
NormalQuat(q);
interp_qt_qtqt(q, bevp0_quat, bevp2->quat, 0.5);
normalize_qt(q);
QuatMulVecf(q, zaxis);
Crossf(cross, zaxis, bevp1->dir);
AxisAngleToQuat(q2, cross, NormalizedVecAngle2(zaxis, bevp1->dir));
NormalQuat(q2);
mul_qt_v3(q, zaxis);
cross_v3_v3v3(cross, zaxis, bevp1->dir);
axis_angle_to_quat(q2, cross, angle_normalized_v3v3(zaxis, bevp1->dir));
normalize_qt(q2);
QUATCOPY(bevp0_quat, bevp1->quat);
QuatMul(q, q2, q);
QuatInterpol(bevp1->quat, bevp1->quat, q, 0.5);
NormalQuat(bevp1->quat);
mul_qt_qtqt(q, q2, q);
interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5);
normalize_qt(bevp1->quat);
bevp0= bevp1;
@ -1716,8 +1716,8 @@ static void make_bevel_list_3D_zup(BevList *bl)
nr= bl->nr;
while(nr--) {
/* totally simple */
VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
vectoquat(bevp1->dir, 5, 1, bevp1->quat);
bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
bevp0= bevp1;
bevp1= bevp2;
@ -1743,15 +1743,15 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
while(nr--) {
if(nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */
vectoquat(bevp1->dir, 5, 1, bevp1->quat);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
}
else {
float angle= NormalizedVecAngle2(bevp0->dir, bevp1->dir);
float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir);
if(angle > 0.0f) { /* otherwise we can keep as is */
Crossf(cross_tmp, bevp0->dir, bevp1->dir);
AxisAngleToQuat(q, cross_tmp, angle);
QuatMul(bevp1->quat, q, bevp0->quat);
cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir);
axis_angle_to_quat(q, cross_tmp, angle);
mul_qt_qtqt(bevp1->quat, q, bevp0->quat);
}
else {
QUATCOPY(bevp1->quat, bevp0->quat);
@ -1788,26 +1788,26 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
bevp_last--;
/* quats and vec's are normalized, should not need to re-normalize */
QuatMulVecf(bevp_first->quat, vec_1);
QuatMulVecf(bevp_last->quat, vec_2);
Normalize(vec_1);
Normalize(vec_2);
mul_qt_v3(bevp_first->quat, vec_1);
mul_qt_v3(bevp_last->quat, vec_2);
normalize_v3(vec_1);
normalize_v3(vec_2);
/* align the vector, can avoid this and it looks 98% OK but
* better to align the angle quat roll's before comparing */
{
Crossf(cross_tmp, bevp_last->dir, bevp_first->dir);
angle = NormalizedVecAngle2(bevp_first->dir, bevp_last->dir);
AxisAngleToQuat(q, cross_tmp, angle);
QuatMulVecf(q, vec_2);
cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir);
angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir);
axis_angle_to_quat(q, cross_tmp, angle);
mul_qt_v3(q, vec_2);
}
angle= NormalizedVecAngle2(vec_1, vec_2);
angle= angle_normalized_v3v3(vec_1, vec_2);
/* flip rotation if needs be */
Crossf(cross_tmp, vec_1, vec_2);
Normalize(cross_tmp);
if(NormalizedVecAngle2(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI))
cross_v3_v3v3(cross_tmp, vec_1, vec_2);
normalize_v3(cross_tmp);
if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI))
angle = -angle;
bevp2= (BevPoint *)(bl+1);
@ -1818,8 +1818,8 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
while(nr--) {
ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */
AxisAngleToQuat(q, bevp1->dir, ang_fac);
QuatMul(bevp1->quat, q, bevp1->quat);
axis_angle_to_quat(q, bevp1->dir, ang_fac);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
bevp0= bevp1;
bevp1= bevp2;
@ -1848,9 +1848,9 @@ static void make_bevel_list_3D_tangent(BevList *bl)
nr= bl->nr;
while(nr--) {
Crossf(cross_tmp, bevp1->tan, bevp1->dir);
Crossf(bevp1->tan, cross_tmp, bevp1->dir);
Normalize(bevp1->tan);
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir);
normalize_v3(bevp1->tan);
bevp0= bevp1;
bevp1= bevp2;
@ -1872,9 +1872,9 @@ static void make_bevel_list_3D_tangent(BevList *bl)
float cross_tmp[3];
float zero[3] = {0,0,0};
Crossf(cross_tmp, bevp1->tan, bevp1->dir);
Normalize(cross_tmp);
triatoquat(zero, cross_tmp, bevp1->tan, bevp1->quat); /* XXX - could be faster */
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
normalize_v3(cross_tmp);
tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */
bevp0= bevp1;
bevp1= bevp2;
@ -2280,14 +2280,14 @@ void makeBevelList(Object *ob)
bevp1= bevp2+1;
/* simple quat/dir */
VecSubf(bevp1->dir, bevp1->vec, bevp2->vec);
Normalize(bevp1->dir);
sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec);
normalize_v3(bevp1->dir);
vectoquat(bevp1->dir, 5, 1, bevp1->quat);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
AxisAngleToQuat(q, bevp1->dir, bevp1->alfa);
QuatMul(bevp1->quat, q, bevp1->quat);
NormalQuat(bevp1->quat);
axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
normalize_qt(bevp1->quat);
VECCOPY(bevp2->dir, bevp1->dir);
QUATCOPY(bevp2->quat, bevp1->quat);
}
@ -2421,10 +2421,10 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
if(leftviolate || rightviolate) { /* align left handle */
float h1[3], h2[3];
VecSubf(h1, p2-3, p2);
VecSubf(h2, p2, p2+3);
len1= Normalize(h1);
len2= Normalize(h2);
sub_v3_v3v3(h1, p2-3, p2);
sub_v3_v3v3(h2, p2, p2+3);
len1= normalize_v3(h1);
len2= normalize_v3(h2);
vz= INPR(h1, h2);
@ -2460,8 +2460,8 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
*(p2+5)= *(p2+2)+dz1;
}
len2= VecLenf(p2, p2+3);
len1= VecLenf(p2, p2-3);
len2= len_v3v3(p2, p2+3);
len1= len_v3v3(p2, p2-3);
if(len1==0.0) len1=1.0;
if(len2==0.0) len2=1.0;
@ -2588,18 +2588,18 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(flag==0 || (bezt1->f1 & flag) ) {
bezt1->h1= 0;
/* distance too short: vectorhandle */
if( VecLenf( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) {
if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) {
bezt1->h1= HD_VECT;
leftsmall= 1;
}
else {
/* aligned handle? */
if(DistVL2Dfl(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) {
if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) {
align= 1;
bezt1->h1= HD_ALIGN;
}
/* or vector handle? */
if(DistVL2Dfl(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001)
if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001)
bezt1->h1= HD_VECT;
}
@ -2608,7 +2608,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(flag==0 || (bezt1->f3 & flag) ) {
bezt1->h2= 0;
/* distance too short: vectorhandle */
if( VecLenf( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) {
if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) {
bezt1->h2= HD_VECT;
rightsmall= 1;
}
@ -2617,7 +2617,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(align) bezt1->h2= HD_ALIGN;
/* or vector handle? */
if(DistVL2Dfl(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001)
if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001)
bezt1->h2= HD_VECT;
}

@ -34,7 +34,7 @@
#include "BKE_customdata.h"
#include "BKE_utildefines.h" // CLAMP
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_mempool.h"
@ -422,21 +422,21 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl
vrat = v - y;
uopp = 1 - urat;
VecCopyf(d[0], disps[y * st + x]);
VecCopyf(d[1], disps[y * st + x2]);
VecCopyf(d[2], disps[y2 * st + x]);
VecCopyf(d[3], disps[y2 * st + x2]);
VecMulf(d[0], uopp);
VecMulf(d[1], urat);
VecMulf(d[2], uopp);
VecMulf(d[3], urat);
copy_v3_v3(d[0], disps[y * st + x]);
copy_v3_v3(d[1], disps[y * st + x2]);
copy_v3_v3(d[2], disps[y2 * st + x]);
copy_v3_v3(d[3], disps[y2 * st + x2]);
mul_v3_fl(d[0], uopp);
mul_v3_fl(d[1], urat);
mul_v3_fl(d[2], uopp);
mul_v3_fl(d[3], urat);
VecAddf(d2[0], d[0], d[1]);
VecAddf(d2[1], d[2], d[3]);
VecMulf(d2[0], 1 - vrat);
VecMulf(d2[1], vrat);
add_v3_v3v3(d2[0], d[0], d[1]);
add_v3_v3v3(d2[1], d[2], d[3]);
mul_v3_fl(d2[0], 1 - vrat);
mul_v3_fl(d2[1], vrat);
VecAddf(out, d2[0], d2[1]);
add_v3_v3v3(out, d2[0], d2[1]);
}
static void layerSwap_mdisps(void *data, int *ci)
@ -452,7 +452,7 @@ static void layerSwap_mdisps(void *data, int *ci)
for(y = 0; y < st; ++y) {
for(x = 0; x < st; ++x) {
VecCopyf(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]);
copy_v3_v3(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]);
}
}
@ -474,7 +474,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight
/* Initialize the destination */
for(i = 0; i < d->totdisp; ++i) {
float z[3] = {0,0,0};
VecCopyf(d->disps[i], z);
copy_v3_v3(d->disps[i], z);
}
/* For now, some restrictions on the input */
@ -505,7 +505,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight
float srcdisp[3];
mdisps_bilinear(srcdisp, s->disps, st, mid3[0], mid3[1]);
VecCopyf(d->disps[y * st + x], srcdisp);
copy_v3_v3(d->disps[y * st + x], srcdisp);
}
}
}

@ -59,7 +59,7 @@
#include "BKE_mesh.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_cellalloc.h"
#ifdef HAVE_CONFIG_H

@ -34,7 +34,7 @@
#endif
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"

@ -56,7 +56,7 @@
#include "DNA_key_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_edgehash.h"
@ -220,12 +220,12 @@ void addnormalsDispList(Object *ob, ListBase *lb)
for(; b<dl->nr; b++) {
CalcNormFloat4(v1, v3, v4, v2, nor);
normal_quad_v3( nor,v1, v3, v4, v2);
VecAddf(n1, n1, nor);
VecAddf(n2, n2, nor);
VecAddf(n3, n3, nor);
VecAddf(n4, n4, nor);
add_v3_v3v3(n1, n1, nor);
add_v3_v3v3(n2, n2, nor);
add_v3_v3v3(n3, n3, nor);
add_v3_v3v3(n4, n4, nor);
v2= v1; v1+= 3;
v4= v3; v3+= 3;
@ -236,7 +236,7 @@ void addnormalsDispList(Object *ob, ListBase *lb)
a= dl->parts*dl->nr;
v1= ndata;
while(a--) {
Normalize(v1);
normalize_v3(v1);
v1+= 3;
}
}
@ -475,11 +475,11 @@ static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, floa
init_fastshade_shadeinput(re);
RE_DataBase_GetView(re, tmat);
Mat4MulMat4(mat, ob->obmat, tmat);
mul_m4_m4m4(mat, ob->obmat, tmat);
Mat4Invert(tmat, mat);
Mat3CpyMat4(imat, tmat);
if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0);
invert_m4_m4(tmat, mat);
copy_m3_m4(imat, tmat);
if(ob->transflag & OB_NEG_SCALE) mul_m3_fl((float *)imat, -1.0);
if (need_orco_r) *need_orco_r= 0;
for(a=0; a<ob->totcol; a++) {
@ -563,7 +563,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
Normalize(vn);
normalize_v3(vn);
}
for (i=0; i<totface; i++) {
@ -586,15 +586,15 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
VECCOPY(nor, &nors[i*3]);
} else {
if (mf->v4)
CalcNormFloat4(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co, nor);
normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
else
CalcNormFloat(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, nor);
normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
}
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalize(n1);
normalize_v3(n1);
for (j=0; j<nverts; j++) {
MVert *mv= &mvert[vidx[j]];
@ -603,7 +603,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
VECCOPY(vec, mv->co);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
vec[0]+= 0.001*vn[0];
vec[1]+= 0.001*vn[1];
vec[2]+= 0.001*vn[2];
@ -708,14 +708,14 @@ void shadeDispList(Scene *scene, Base *base)
n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2];
n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2];
n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2];
Normalize(n1);
normalize_v3(n1);
fp= dl->verts;
a= dl->nr;
while(a--) {
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
@ -731,12 +731,12 @@ void shadeDispList(Scene *scene, Base *base)
while(a--) {
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalize(n1);
normalize_v3(n1);
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
@ -769,13 +769,13 @@ void shadeDispList(Scene *scene, Base *base)
a= dl->nr;
while(a--) {
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
/* transpose ! */
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalize(n1);
normalize_v3(n1);
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
@ -1612,7 +1612,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
vec[1]= fp1[2];
vec[2]= 0.0;
QuatMulVecf(bevp->quat, vec);
mul_qt_v3(bevp->quat, vec);
data[0]= bevp->vec[0] + fac*vec[0];
data[1]= bevp->vec[1] + fac*vec[1];

@ -52,7 +52,7 @@
#include "DNA_space_types.h"
#include "DNA_particle_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_edgehash.h"
@ -1670,10 +1670,10 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *ob,
float *v3 = vertexCos[(int) BMINDEX_GET(l[2]->v)];
float *no = bmdm->faceNos[i];
CalcNormFloat(v1, v2, v3, no);
VecAddf(bmdm->vertexNos[BMINDEX_GET(l[0]->v)], bmdm->vertexNos[BMINDEX_GET(l[0]->v)], no);
VecAddf(bmdm->vertexNos[BMINDEX_GET(l[1]->v)], bmdm->vertexNos[BMINDEX_GET(l[1]->v)], no);
VecAddf(bmdm->vertexNos[BMINDEX_GET(l[2]->v)], bmdm->vertexNos[BMINDEX_GET(l[2]->v)], no);
normal_tri_v3( no,v1, v2, v3);
add_v3_v3v3(bmdm->vertexNos[BMINDEX_GET(l[0]->v)], bmdm->vertexNos[BMINDEX_GET(l[0]->v)], no);
add_v3_v3v3(bmdm->vertexNos[BMINDEX_GET(l[1]->v)], bmdm->vertexNos[BMINDEX_GET(l[1]->v)], no);
add_v3_v3v3(bmdm->vertexNos[BMINDEX_GET(l[2]->v)], bmdm->vertexNos[BMINDEX_GET(l[2]->v)], no);
}
eve=BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
@ -1681,9 +1681,9 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *ob,
float *no = bmdm->vertexNos[i];
/* following Mesh convention; we use vertex coordinate itself
* for normal in this case */
if (Normalize(no)==0.0) {
if (normalize_v3(no)==0.0) {
VECCOPY(no, vertexCos[i]);
Normalize(no);
normalize_v3(no);
}
}
}

@ -52,7 +52,7 @@
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_jitter.h"
#include "BLI_listbase.h"
@ -221,8 +221,8 @@ static void precalculate_effector(EffectorCache *eff)
if(cu->path && cu->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius);
Mat4MulVecfl(eff->ob->obmat, eff->guide_loc);
Mat4Mul3Vecfl(eff->ob->obmat, eff->guide_dir);
mul_m4_v3(eff->ob->obmat, eff->guide_loc);
mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir);
}
}
}
@ -433,8 +433,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
return visibility;
VECCOPY(norm, efd->vec_to_point);
VecNegf(norm);
len = Normalize(norm);
negate_v3(norm);
len = normalize_v3(norm);
// check all collision objects
for(col = colls->first; col; col = col->next)
@ -520,7 +520,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi
float falloff = weights ? weights->weight[0] * weights->weight[eff->pd->forcefield] : 1.0f;
float fac, r_fac;
fac = Inpf(efd->nor, efd->vec_to_point2);
fac = dot_v3v3(efd->nor, efd->vec_to_point2);
if(eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f)
falloff=0.0f;
@ -537,7 +537,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi
break;
VECADDFAC(temp, efd->vec_to_point, efd->nor, -fac);
r_fac= VecLength(temp);
r_fac= len_v3(temp);
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
case PFIELD_FALL_CONE:
@ -545,7 +545,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi
if(falloff == 0.0f)
break;
r_fac=saacos(fac/VecLength(efd->vec_to_point))*180.0f/(float)M_PI;
r_fac=saacos(fac/len_v3(efd->vec_to_point))*180.0f/(float)M_PI;
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
@ -574,12 +574,12 @@ int closest_point_on_surface(SurfaceModifierData *surmd, float *co, float *surfa
MFace *mface = CDDM_get_tessface(surmd->dm, nearest.index);
VECCOPY(surface_vel, surmd->v[mface->v1].co);
VecAddf(surface_vel, surface_vel, surmd->v[mface->v2].co);
VecAddf(surface_vel, surface_vel, surmd->v[mface->v3].co);
add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v2].co);
add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v3].co);
if(mface->v4)
VecAddf(surface_vel, surface_vel, surmd->v[mface->v4].co);
add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v4].co);
VecMulf(surface_vel, mface->v4 ? 0.25f : 0.333f);
mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f);
}
return 1;
}
@ -596,9 +596,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
float vec[3];
/* using velocity corrected location allows for easier sliding over effector surface */
VecCopyf(vec, point->vel);
VecMulf(vec, point->vel_to_frame);
VecAddf(vec, vec, point->loc);
copy_v3_v3(vec, point->vel);
mul_v3_fl(vec, point->vel_to_frame);
add_v3_v3v3(vec, vec, point->loc);
ret = closest_point_on_surface(eff->surmd, vec, efd->loc, efd->nor, real_velocity ? efd->vel : NULL);
@ -612,10 +612,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
dm->getVertCo(dm, *efd->index, efd->loc);
dm->getVertNo(dm, *efd->index, efd->nor);
Mat4MulVecfl(eff->ob->obmat, efd->loc);
Mat4Mul3Vecfl(eff->ob->obmat, efd->nor);
mul_m4_v3(eff->ob->obmat, efd->loc);
mul_mat3_m4_v3(eff->ob->obmat, efd->nor);
Normalize(efd->nor);
normalize_v3(efd->nor);
efd->size = 0.0f;
@ -660,15 +660,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
/* use z-axis as normal*/
VECCOPY(efd->nor, ob->obmat[2]);
Normalize(efd->nor);
normalize_v3(efd->nor);
/* for vortex the shape chooses between old / new force */
if(eff->pd->shape == PFIELD_SHAPE_PLANE) {
/* efd->loc is closes point on effector xy-plane */
float temp[3];
VecSubf(temp, point->loc, ob->obmat[3]);
Projf(efd->loc, temp, efd->nor);
VecSubf(efd->loc, point->loc, efd->loc);
sub_v3_v3v3(temp, point->loc, ob->obmat[3]);
project_v3_v3v3(efd->loc, temp, efd->nor);
sub_v3_v3v3(efd->loc, point->loc, efd->loc);
}
else {
VECCOPY(efd->loc, ob->obmat[3]);
@ -679,7 +679,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
where_is_object_time(eff->scene, ob, cfra - 1.0);
VecSubf(efd->vel, efd->vel, ob->obmat[3]);
sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]);
}
*eff->ob = obcopy;
@ -690,8 +690,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
if(ret) {
VecSubf(efd->vec_to_point, point->loc, efd->loc);
efd->distance = VecLength(efd->vec_to_point);
sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc);
efd->distance = len_v3(efd->vec_to_point);
if(eff->flag & PE_USE_NORMAL_DATA) {
VECCOPY(efd->vec_to_point2, efd->vec_to_point);
@ -699,9 +699,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
else {
/* for some effectors we need the object center every time */
VecSubf(efd->vec_to_point2, point->loc, eff->ob->obmat[3]);
sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->obmat[3]);
VECCOPY(efd->nor2, eff->ob->obmat[2]);
Normalize(efd->nor2);
normalize_v3(efd->nor2);
}
}
@ -764,12 +764,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
VECCOPY(tex_co,point->loc);
if(eff->pd->flag & PFIELD_TEX_2D) {
float fac=-Inpf(tex_co, efd->nor);
float fac=-dot_v3v3(tex_co, efd->nor);
VECADDFAC(tex_co, tex_co, efd->nor, fac);
}
if(eff->pd->flag & PFIELD_TEX_OBJECT) {
Mat4Mul3Vecfl(eff->ob->obmat, tex_co);
mul_mat3_m4_v3(eff->ob->obmat, tex_co);
}
hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 1, result);
@ -815,11 +815,11 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
}
if(eff->pd->flag & PFIELD_TEX_2D){
float fac = -Inpf(force, efd->nor);
float fac = -dot_v3v3(force, efd->nor);
VECADDFAC(force, force, efd->nor, fac);
}
VecAddf(total_force, total_force, force);
add_v3_v3v3(total_force, total_force, force);
}
void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
{
@ -844,51 +844,51 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
switch(pd->forcefield){
case PFIELD_WIND:
VECCOPY(force, efd->nor);
VecMulf(force, strength * efd->falloff);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_FORCE:
Normalize(force);
VecMulf(force, strength * efd->falloff);
normalize_v3(force);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_VORTEX:
/* old vortex force */
if(pd->shape == PFIELD_SHAPE_POINT) {
Crossf(force, efd->nor, efd->vec_to_point);
Normalize(force);
VecMulf(force, strength * efd->distance * efd->falloff);
cross_v3_v3v3(force, efd->nor, efd->vec_to_point);
normalize_v3(force);
mul_v3_fl(force, strength * efd->distance * efd->falloff);
}
else {
/* new vortex force */
Crossf(temp, efd->nor2, efd->vec_to_point2);
VecMulf(temp, strength * efd->falloff);
cross_v3_v3v3(temp, efd->nor2, efd->vec_to_point2);
mul_v3_fl(temp, strength * efd->falloff);
Crossf(force, efd->nor2, temp);
VecMulf(force, strength * efd->falloff);
cross_v3_v3v3(force, efd->nor2, temp);
mul_v3_fl(force, strength * efd->falloff);
VECADDFAC(temp, temp, point->vel, -point->vel_to_sec);
VecAddf(force, force, temp);
add_v3_v3v3(force, force, temp);
}
break;
case PFIELD_MAGNET:
if(eff->pd->shape == PFIELD_SHAPE_POINT)
/* magnetic field of a moving charge */
Crossf(temp, efd->nor, efd->vec_to_point);
cross_v3_v3v3(temp, efd->nor, efd->vec_to_point);
else
VecCopyf(temp, efd->nor);
copy_v3_v3(temp, efd->nor);
Normalize(temp);
VecMulf(temp, strength * efd->falloff);
Crossf(force, point->vel, temp);
VecMulf(force, point->vel_to_sec);
normalize_v3(temp);
mul_v3_fl(temp, strength * efd->falloff);
cross_v3_v3v3(force, point->vel, temp);
mul_v3_fl(force, point->vel_to_sec);
break;
case PFIELD_HARMONIC:
VecMulf(force, -strength * efd->falloff);
VecCopyf(temp, point->vel);
VecMulf(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec);
VecAddf(force, force, temp);
mul_v3_fl(force, -strength * efd->falloff);
copy_v3_v3(temp, point->vel);
mul_v3_fl(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec);
add_v3_v3v3(force, force, temp);
break;
case PFIELD_CHARGE:
VecMulf(force, point->charge * strength * efd->falloff);
mul_v3_fl(force, point->charge * strength * efd->falloff);
break;
case PFIELD_LENNARDJ:
fac = pow((efd->size + point->size) / efd->distance, 6.0);
@ -898,7 +898,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
/* limit the repulsive term drastically to avoid huge forces */
fac = ((fac>2.0) ? 2.0 : fac);
VecMulf(force, strength * fac);
mul_v3_fl(force, strength * fac);
break;
case PFIELD_BOID:
/* Boid field is handled completely in boids code. */
@ -913,16 +913,16 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2,0,2);
force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2,0,2);
force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2,0,2);
VecMulf(force, strength * efd->falloff);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_DRAG:
VECCOPY(force, point->vel);
fac = Normalize(force) * point->vel_to_sec;
fac = normalize_v3(force) * point->vel_to_sec;
strength = MIN2(strength, 2.0f);
damp = MIN2(damp, 2.0f);
VecMulf(force, -efd->falloff * fac * (strength * fac + damp));
mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));
break;
}
@ -937,12 +937,12 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
if(pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) {
float xvec[3] = {1.0f, 0.0f, 0.0f};
float dave[3];
QuatMulVecf(point->rot, xvec);
Crossf(dave, xvec, force);
mul_qt_v3(point->rot, xvec);
cross_v3_v3v3(dave, xvec, force);
if(pd->f_flow != 0.0f) {
VECADDFAC(dave, dave, point->ave, -pd->f_flow * efd->falloff);
}
VecAddf(point->ave, point->ave, dave);
add_v3_v3v3(point->ave, point->ave, dave);
}
}

@ -64,7 +64,7 @@
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BKE_blender.h"
@ -180,7 +180,7 @@ static void mesh_add_normals_flags(Mesh *me)
v3= me->mvert+mface->v3;
v4= me->mvert+mface->v4;
CalcNormFloat(v1->co, v2->co, v3->co, nor);
normal_tri_v3( nor,v1->co, v2->co, v3->co);
sno[0]= 32767.0*nor[0];
sno[1]= 32767.0*nor[1];
sno[2]= 32767.0*nor[2];
@ -1249,7 +1249,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
VECCOPY(bp->vec, data);
if(coordtype==4) {
bp->vec[3]= data[3];
VecMulf(bp->vec, 1.0f/data[3]);
mul_v3_fl(bp->vec, 1.0f/data[3]);
}
else bp->vec[3]= 1.0;
data+= coordtype;
@ -1837,7 +1837,7 @@ static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL)
float vert[3];
VECCOPY(vert, verts[(index)].co);
Mat4MulVecfl(ob->obmat, vert);
mul_m4_v3(ob->obmat, vert);
if (ENDIAN_ORDER==B_ENDIAN) {
SWITCH_INT(vert[0]);
@ -2174,7 +2174,7 @@ static void write_camera_vrml(FILE *fp, Object *ob)
Camera *cam;
if(ob==0) return;
Mat4Invert(ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
fprintf(fp, "\tMatrixTransform {\n");
@ -3031,10 +3031,10 @@ static void dxf_read_line(Scene *scene, int noob) {
mvert= &me->mvert[(me->totvert-2)];
VecSubf(mvert->co, cent, vcenter);
sub_v3_v3v3(mvert->co, cent, vcenter);
mvert++;
if (vspace) { VECCOPY(mvert->co, epoint);
} else VecSubf(mvert->co, epoint, vcenter);
} else sub_v3_v3v3(mvert->co, epoint, vcenter);
mface= &(((MFace*)me->mface)[me->totface-1]);
mface->v1= me->totvert-2;
@ -3237,7 +3237,7 @@ static void dxf_read_ellipse(Scene *scene, int noob)
if (vspace) {
VECCOPY(mvert->co, epoint);
} else {
VecSubf(mvert->co, epoint, vcenter);
sub_v3_v3v3(mvert->co, epoint, vcenter);
}
if (v > 0) {
@ -3360,7 +3360,7 @@ static void dxf_read_arc(Scene *scene, int noob)
if (vspace) {
VECCOPY(mvert->co, epoint);
} else {
VecSubf(mvert->co, epoint, vcenter);
sub_v3_v3v3(mvert->co, epoint, vcenter);
}
if (v > 0) {
@ -3470,7 +3470,7 @@ static void dxf_read_polyline(Scene *scene, int noob) {
mvert= &me->mvert[me->totvert-1];
if (vspace) { VECCOPY(mvert->co, vert);
} else VecSubf(mvert->co, vert, vcenter);
} else sub_v3_v3v3(mvert->co, vert, vcenter);
}
/* make edges */
@ -3556,7 +3556,7 @@ static void dxf_read_polyline(Scene *scene, int noob) {
mvert= &me->mvert[(me->totvert-1)];
if (vspace) { VECCOPY(mvert->co, vert);
} else VecSubf(mvert->co, vert, vcenter);
} else sub_v3_v3v3(mvert->co, vert, vcenter);
} else if (vflags & 128) {
if(vids[2]==0) {
@ -3687,7 +3687,7 @@ static void dxf_read_lwpolyline(Scene *scene, int noob) {
if (vspace) {
VECCOPY(mvert->co, vert);
} else {
VecSubf(mvert->co, vert, vcenter);
sub_v3_v3v3(mvert->co, vert, vcenter);
}
if (v > 0) {
@ -3859,20 +3859,20 @@ static void dxf_read_3dface(Scene *scene, int noob)
ftmp=NULL;
mvert= &me->mvert[(me->totvert-nverts)];
VecSubf(mvert->co, cent, vcenter);
sub_v3_v3v3(mvert->co, cent, vcenter);
mvert++;
if (vspace) { VECCOPY(mvert->co, vert2);
} else VecSubf(mvert->co, vert2, vcenter);
} else sub_v3_v3v3(mvert->co, vert2, vcenter);
mvert++;
if (vspace) { VECCOPY(mvert->co, vert3);
} else VecSubf(mvert->co, vert3, vcenter);
} else sub_v3_v3v3(mvert->co, vert3, vcenter);
if (nverts==4) {
mvert++;
if (vspace) { VECCOPY(mvert->co, vert4);
} else VecSubf(mvert->co, vert4, vcenter);
} else sub_v3_v3v3(mvert->co, vert4, vcenter);
}
mface= &(((MFace*)me->mface)[me->totface-1]);

@ -43,7 +43,7 @@
#include "DNA_anim_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BKE_fcurve.h"
@ -924,11 +924,11 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
}
/* use the final posed locations */
Mat4ToQuat(pchan->pose_mat, q1);
Mat4ToQuat(pchan2->pose_mat, q2);
mat4_to_quat( q1,pchan->pose_mat);
mat4_to_quat( q2,pchan2->pose_mat);
QuatInv(q1);
QuatMul(quat, q1, q2);
invert_qt(q1);
mul_qt_qtqt(quat, q1, q2);
angle = 2.0f * (saacos(quat[0]));
angle= ABS(angle);
@ -1017,13 +1017,13 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o)
if (d > 0.0) {
t= sqrt(d);
o[0]= (float)(Sqrt3d(-q+t) + Sqrt3d(-q-t) - a);
o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a);
if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1;
else return 0;
}
else if (d == 0.0) {
t= Sqrt3d(-q);
t= sqrt3d(-q);
o[0]= (float)(2*t - a);
if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++;

@ -40,7 +40,7 @@
#include "DNA_particle_types.h"
#include "DNA_scene_types.h" // N_T
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BKE_cdderivedmesh.h"
@ -564,13 +564,13 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
float vec[3];
VECCOPY(vec, mvert[0].co);
Mat4MulVecfl(obmat, vec);
mul_m4_v3(obmat, vec);
bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2];
bbex = vec[0]; bbey = vec[1]; bbez = vec[2];
for(i = 1; i < totvert; i++) {
VECCOPY(vec, mvert[i].co);
Mat4MulVecfl(obmat, vec);
mul_m4_v3(obmat, vec);
if(vec[0] < bbsx){ bbsx= vec[0]; }
if(vec[1] < bbsy){ bbsy= vec[1]; }
@ -627,7 +627,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
verts = MEM_callocN( totvert*3*sizeof(float), "elbeemmesh_vertices");
for(i=0; i<totvert; i++) {
VECCOPY( &verts[i*3], mvert[i].co);
if(useGlobalCoords) { Mat4MulVecfl(ob->obmat, &verts[i*3]); }
if(useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); }
}
*vertices = verts;

@ -41,7 +41,7 @@
#include "DNA_anim_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BKE_fcurve.h"

@ -41,7 +41,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_vfontdata.h"
@ -968,12 +968,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
float minx, maxx, miny, maxy;
float timeofs, sizefac;
Mat4Invert(imat, ob->obmat);
Mat3CpyMat4(imat3, imat);
invert_m4_m4(imat, ob->obmat);
copy_m3_m4(imat3, imat);
Mat3CpyMat4(cmat, cu->textoncurve->obmat);
Mat3MulMat3(cmat, cmat, imat3);
sizefac= Normalize(cmat[0])/cu->fsize;
copy_m3_m4(cmat, cu->textoncurve->obmat);
mul_m3_m3m3(cmat, cmat, imat3);
sizefac= normalize_v3(cmat[0])/cu->fsize;
minx=miny= 1.0e20f;
maxx=maxy= -1.0e20f;
@ -1042,7 +1042,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL);
where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL);
VecMulf(vec, sizefac);
mul_v3_fl(vec, sizefac);
ct->rot= (float)(M_PI-atan2(rotvec[1], rotvec[0]));
@ -1196,7 +1196,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
vecyo[0] = ct->xof;
vecyo[1] = ct->yof;
vecyo[2] = 0;
Mat4MulVecfl(ob->obmat, vecyo);
mul_m4_v3(ob->obmat, vecyo);
VECCOPY(ob->loc, vecyo);
outta = 1;
cu->sepchar = 0;

@ -36,7 +36,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "DNA_listBase.h"

@ -61,7 +61,7 @@
#include "DNA_sequence_types.h"
#include "DNA_userdef_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_threads.h"

@ -1550,28 +1550,28 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF,
CalcFloat(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],triunnormal);
VECCOPY(trinormal, triunnormal);
Normalize(trinormal);
normalize_v3(trinormal);
// add wind from v1
VECCOPY(tmp, trinormal);
VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal));
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal));
VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor);
// add wind from v2
VECCOPY(tmp, trinormal);
VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal));
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal));
VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor);
// add wind from v3
VECCOPY(tmp, trinormal);
VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal));
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal));
VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
// add wind from v4
if(mfaces[i].v4)
{
VECCOPY(tmp, trinormal);
VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
}
}
@ -1652,7 +1652,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
if(verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
VECSUB(id->V[i], verts[i].xconst, verts[i].xold);
// VecMulf(id->V[i], clmd->sim_parms->stepsPerFrame);
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
}
}
}
@ -1725,7 +1725,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
VECCOPY(id->Xnew[i], verts[i].tx);
VECCOPY(id->Vnew[i], verts[i].tv);
VecMulf(id->Vnew[i], clmd->sim_parms->stepsPerFrame);
mul_v3_fl(id->Vnew[i], clmd->sim_parms->stepsPerFrame);
}
}

@ -70,7 +70,7 @@
#include "DNA_world_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "BKE_utildefines.h"

@ -39,7 +39,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_cellalloc.h"
#include "DNA_armature_types.h"
@ -156,10 +156,10 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
/* prevent using deformed locations */
freedisplist(&ltOb->disp);
Mat4CpyMat4(mat, ltOb->obmat);
Mat4One(ltOb->obmat);
copy_m4_m4(mat, ltOb->obmat);
unit_m4(ltOb->obmat);
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL);
Mat4CpyMat4(ltOb->obmat, mat);
copy_m4_m4(ltOb->obmat, mat);
lt->typeu = typeu;
lt->typev = typev;
@ -311,18 +311,18 @@ void init_latt_deform(Object *oblatt, Object *ob)
/* for example with a particle system: ob==0 */
if(ob==NULL) {
/* in deformspace, calc matrix */
Mat4Invert(lt->latmat, oblatt->obmat);
invert_m4_m4(lt->latmat, oblatt->obmat);
/* back: put in deform array */
Mat4Invert(imat, lt->latmat);
invert_m4_m4(imat, lt->latmat);
}
else {
/* in deformspace, calc matrix */
Mat4Invert(imat, oblatt->obmat);
Mat4MulMat4(lt->latmat, ob->obmat, imat);
invert_m4_m4(imat, oblatt->obmat);
mul_m4_m4m4(lt->latmat, ob->obmat, imat);
/* back: put in deform array */
Mat4Invert(imat, lt->latmat);
invert_m4_m4(imat, lt->latmat);
}
for(w=0,fw=lt->fw; w<lt->pntsw; w++,fw+=lt->dw) {
@ -338,7 +338,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
fp[2] = bp->vec[2] - fw;
}
Mat4Mul3Vecfl(imat, fp);
mul_mat3_m4_v3(imat, fp);
}
}
}
@ -357,7 +357,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
/* co is in local coords, treat with latmat */
VECCOPY(vec, co);
Mat4MulVecfl(lt->latmat, vec);
mul_m4_v3(lt->latmat, vec);
/* u v w coords */
@ -457,15 +457,15 @@ typedef struct {
static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc)
{
Mat4Invert(ob->imat, ob->obmat);
Mat4MulMat4(cd->objectspace, par->obmat, ob->imat);
Mat4Invert(cd->curvespace, cd->objectspace);
Mat3CpyMat4(cd->objectspace3, cd->objectspace);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat);
invert_m4_m4(cd->curvespace, cd->objectspace);
copy_m3_m4(cd->objectspace3, cd->objectspace);
// offset vector for 'no smear'
if(dloc) {
Mat4Invert(par->imat, par->obmat);
VecMat4MulVecfl(cd->dloc, par->imat, ob->obmat[3]);
invert_m4_m4(par->imat, par->obmat);
mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]);
}
else cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f;
@ -498,15 +498,15 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir,
float dvec[3];
if(ctime < 0.0) {
VecSubf(dvec, path->data[1].vec, path->data[0].vec);
VecMulf(dvec, ctime*(float)path->len);
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
mul_v3_fl(dvec, ctime*(float)path->len);
VECADD(vec, vec, dvec);
if(quat) QUATCOPY(quat, path->data[0].quat);
if(radius) *radius= path->data[0].radius;
}
else if(ctime > 1.0) {
VecSubf(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
VecMulf(dvec, (ctime-1.0)*(float)path->len);
sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
mul_v3_fl(dvec, (ctime-1.0)*(float)path->len);
VECADD(vec, vec, dvec);
if(quat) QUATCOPY(quat, path->data[path->len-1].quat);
if(radius) *radius= path->data[path->len-1].radius;
@ -571,28 +571,28 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
dir[cd->no_rot_axis-1]= 0.0f;
/* -1 for compatibility with old track defines */
vectoquat(dir, axis-1, upflag, quat);
vec_to_quat( quat,dir, axis-1, upflag);
/* the tilt */
if(loc[3]!=0.0) {
Normalize(dir);
normalize_v3(dir);
q[0]= (float)cos(0.5*loc[3]);
fac= (float)sin(0.5*loc[3]);
q[1]= -fac*dir[0];
q[2]= -fac*dir[1];
q[3]= -fac*dir[2];
QuatMul(quat, q, quat);
mul_qt_qtqt(quat, q, quat);
}
#endif
static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180));
static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180));
static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; AxisAngleToQuat(q, rot_axis, 90 * (M_PI / 180));
static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180));
static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180));
static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; AxisAngleToQuat(q, rot_axis, -90 * (M_PI / 180));
static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
if(cd->no_rot_axis) { /* set by caller */
@ -603,12 +603,12 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
VECCOPY(dir_flat, dir);
dir_flat[cd->no_rot_axis-1]= 0.0f;
Normalize(dir);
Normalize(dir_flat);
normalize_v3(dir);
normalize_v3(dir_flat);
RotationBetweenVectorsToQuat(q, dir, dir_flat); /* Could this be done faster? */
rotation_between_vecs_to_quat(q, dir, dir_flat); /* Could this be done faster? */
QuatMul(new_quat, q, new_quat);
mul_qt_qtqt(new_quat, q, new_quat);
}
@ -625,14 +625,14 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
switch(axis) {
case MOD_CURVE_POSX:
QuatMul(quat, new_quat, q_y90d);
mul_qt_qtqt(quat, new_quat, q_y90d);
cent[0]= 0.0;
cent[1]= co[2];
cent[2]= co[1];
break;
case MOD_CURVE_NEGX:
QuatMul(quat, new_quat, q_ny90d);
mul_qt_qtqt(quat, new_quat, q_ny90d);
cent[0]= 0.0;
cent[1]= -co[1];
@ -640,28 +640,28 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
break;
case MOD_CURVE_POSY:
QuatMul(quat, new_quat, q_x90d);
mul_qt_qtqt(quat, new_quat, q_x90d);
cent[0]= co[2];
cent[1]= 0.0;
cent[2]= -co[0];
break;
case MOD_CURVE_NEGY:
QuatMul(quat, new_quat, q_nx90d);
mul_qt_qtqt(quat, new_quat, q_nx90d);
cent[0]= -co[0];
cent[1]= 0.0;
cent[2]= -co[2];
break;
case MOD_CURVE_POSZ:
QuatMul(quat, new_quat, q_z90d);
mul_qt_qtqt(quat, new_quat, q_z90d);
cent[0]= co[1];
cent[1]= -co[0];
cent[2]= 0.0;
break;
case MOD_CURVE_NEGZ:
QuatMul(quat, new_quat, q_nz90d);
mul_qt_qtqt(quat, new_quat, q_nz90d);
cent[0]= co[0];
cent[1]= -co[1];
@ -671,11 +671,11 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
/* scale if enabled */
if(cu->flag & CU_PATH_RADIUS)
VecMulf(cent, radius);
mul_v3_fl(cent, radius);
/* local rotation */
NormalQuat(quat);
QuatMulVecf(quat, cent);
normalize_qt(quat);
mul_qt_v3(quat, cent);
/* translation */
VECADD(co, cent, loc);
@ -740,7 +740,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh
for(j = 0; j < dvert->totweight; j++) {
if(dvert->dw[j].def_nr == index) {
Mat4MulVecfl(cd.curvespace, vertexCos[a]);
mul_m4_v3(cd.curvespace, vertexCos[a]);
DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
break;
}
@ -755,9 +755,9 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh
if(dvert->dw[j].def_nr == index) {
VECCOPY(vec, vertexCos[a]);
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
VecLerpf(vertexCos[a], vertexCos[a], vec,
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec,
dvert->dw[j].weight);
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
mul_m4_v3(cd.objectspace, vertexCos[a]);
break;
}
}
@ -767,13 +767,13 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh
INIT_MINMAX(cd.dmin, cd.dmax);
for(a = 0; a < numVerts; a++) {
Mat4MulVecfl(cd.curvespace, vertexCos[a]);
mul_m4_v3(cd.curvespace, vertexCos[a]);
DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
}
for(a = 0; a < numVerts; a++) {
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
}
cu->flag = flag;
@ -788,7 +788,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco
float quat[4];
if(cuOb->type != OB_CURVE) {
Mat3One(mat);
unit_m3(mat);
return;
}
@ -798,18 +798,18 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco
VECCOPY(cd.dmin, orco);
VECCOPY(cd.dmax, orco);
Mat4MulVecfl(cd.curvespace, vec);
mul_m4_v3(cd.curvespace, vec);
if(calc_curve_deform(scene, cuOb, vec, target->trackflag+1, &cd, quat)) {
float qmat[3][3];
QuatToMat3(quat, qmat);
Mat3MulMat3(mat, qmat, cd.objectspace3);
quat_to_mat3( qmat,quat);
mul_m3_m3m3(mat, qmat, cd.objectspace3);
}
else
Mat3One(mat);
unit_m3(mat);
Mat4MulVecfl(cd.objectspace, vec);
mul_m4_v3(cd.objectspace, vec);
}
@ -940,7 +940,7 @@ void outside_lattice(Lattice *lt)
bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
VecMulf(bp->vec, 0.3333333f);
mul_v3_fl(bp->vec, 0.3333333f);
}
}

@ -46,7 +46,7 @@
#include "DNA_userdef_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_animsys.h"
#include "BKE_blender.h"

@ -47,7 +47,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_utildefines.h"
@ -436,7 +436,7 @@ Object *find_basis_mball(Scene *scene, Object *basis)
void calc_mballco(MetaElem *ml, float *vec)
{
if(ml->mat) {
Mat4MulVecfl((float ( * )[4])ml->mat, vec);
mul_m4_v3((float ( * )[4])ml->mat, vec);
}
}
@ -448,7 +448,7 @@ float densfunc(MetaElem *ball, float x, float y, float z)
vec[0]= x;
vec[1]= y;
vec[2]= z;
Mat4MulVecfl((float ( * )[4])ball->imat, vec);
mul_m4_v3((float ( * )[4])ball->imat, vec);
dx= vec[0];
dy= vec[1];
dz= vec[2];
@ -1508,8 +1508,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
int a, obnr, zero_size=0;
char obname[32];
Mat4CpyMat4(obmat, ob->obmat); /* to cope with duplicators from next_object */
Mat4Invert(obinv, ob->obmat);
copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from next_object */
invert_m4_m4(obinv, ob->obmat);
a= 0;
splitIDname(ob->id.name+2, obname, &obnr);
@ -1581,15 +1581,15 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
if(ml->s > 10.0) ml->s = 10.0;
/* Rotation of MetaElem is stored in quat */
QuatToMat4(ml->quat, temp3);
quat_to_mat4( temp3,ml->quat);
/* Translation of MetaElem */
Mat4One(temp2);
unit_m4(temp2);
temp2[3][0]= ml->x;
temp2[3][1]= ml->y;
temp2[3][2]= ml->z;
Mat4MulMat4(temp1, temp3, temp2);
mul_m4_m4m4(temp1, temp3, temp2);
/* make a copy because of duplicates */
mainb[a]= new_pgn_element(sizeof(MetaElem));
@ -1600,12 +1600,12 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
imat= new_pgn_element(4*4*sizeof(float));
/* mat is the matrix to transform from mball into the basis-mball */
Mat4Invert(obinv, obmat);
Mat4MulMat4(temp2, bob->obmat, obinv);
invert_m4_m4(obinv, obmat);
mul_m4_m4m4(temp2, bob->obmat, obinv);
/* MetaBall transformation */
Mat4MulMat4(mat, temp1, temp2);
mul_m4_m4m4(mat, temp1, temp2);
Mat4Invert(imat,mat);
invert_m4_m4(imat,mat);
mainb[a]->rad2= ml->rad*ml->rad;
@ -1648,7 +1648,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* transformation of Metalem bb */
for(i=0; i<8; i++)
Mat4MulVecfl((float ( * )[4])mat, mainb[a]->bb->vec[i]);
mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]);
/* find max and min of transformed bb */
for(i=0; i<8; i++){

@ -71,7 +71,7 @@
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_cellalloc.h"
#include "BLI_array.h"
#include "BLI_edgehash.h"
@ -1220,7 +1220,7 @@ void mesh_to_curve(Scene *scene, Object *ob)
/* add points */
vl= polyline.first;
for (i=0, bp=nu->bp; i < totpoly; i++, bp++, vl=(VertLink *)vl->next) {
VecCopyf(bp->vec, mverts[vl->index].co);
copy_v3_v3(bp->vec, mverts[vl->index].co);
bp->f1= SELECT;
bp->radius = bp->weight = 1.0;
}
@ -1280,23 +1280,23 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces,
float *f_no= &fnors[i*3];
if (mf->v4)
CalcNormFloat4(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co, f_no);
normal_quad_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co);
else
CalcNormFloat(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, f_no);
normal_tri_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co);
VecAddf(tnorms[mf->v1], tnorms[mf->v1], f_no);
VecAddf(tnorms[mf->v2], tnorms[mf->v2], f_no);
VecAddf(tnorms[mf->v3], tnorms[mf->v3], f_no);
add_v3_v3v3(tnorms[mf->v1], tnorms[mf->v1], f_no);
add_v3_v3v3(tnorms[mf->v2], tnorms[mf->v2], f_no);
add_v3_v3v3(tnorms[mf->v3], tnorms[mf->v3], f_no);
if (mf->v4)
VecAddf(tnorms[mf->v4], tnorms[mf->v4], f_no);
add_v3_v3v3(tnorms[mf->v4], tnorms[mf->v4], f_no);
}
for (i=0; i<numVerts; i++) {
MVert *mv= &mverts[i];
float *no= tnorms[i];
if (Normalize(no)==0.0) {
if (normalize_v3(no)==0.0) {
VECCOPY(no, mv->co);
Normalize(no);
normalize_v3(no);
}
mv->no[0]= (short)(no[0]*32767.0);
@ -1396,7 +1396,7 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned
next= iterv->next;
uv2= (tf+iterv->f)->uv[iterv->tfindex];
Vec2Subf(uvdiff, uv2, uv);
sub_v2_v2v2(uvdiff, uv2, uv);
if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) {
@ -1787,7 +1787,7 @@ void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart,
v1 = mvarray + (loopstart++)->v;
v2 = mvarray + (loopstart++)->v;
v3 = mvarray + loopstart->v;
CalcNormFloat(v1->co, v2->co, v3->co, no);
normal_tri_v3( no,v1->co, v2->co, v3->co);
}
else if(mpoly->totloop == 4){
MVert *v1, *v2, *v3, *v4;
@ -1796,7 +1796,7 @@ void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart,
v2 = mvarray + (loopstart++)->v;
v3 = mvarray + (loopstart++)->v;
v4 = mvarray + loopstart->v;
CalcNormFloat4(v1->co, v2->co, v3->co, v4->co, no);
normal_quad_v3( no,v1->co, v2->co, v3->co, v4->co);
}
else{ /*horrible, two sided face!*/
no[0] = 0.0;

@ -42,7 +42,7 @@
#include "float.h"
#include "ctype.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_kdopbvh.h"
#include "BLI_kdtree.h"
@ -1196,7 +1196,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(amd->end_cap && amd->end_cap != ob)
end_cap = amd->end_cap->derivedFinal;
Mat4One(offset);
unit_m4(offset);
indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm),
"indexmap");
@ -1206,7 +1206,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
maxVerts = dm->getNumVerts(dm);
if(amd->offset_type & MOD_ARR_OFF_CONST)
VecAddf(offset[3], offset[3], amd->offset);
add_v3_v3v3(offset[3], offset[3], amd->offset);
if(amd->offset_type & MOD_ARR_OFF_RELATIVE) {
for(j = 0; j < 3; j++)
offset[3][j] += amd->scale[j] * vertarray_size(src_mvert,
@ -1218,14 +1218,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
float result_mat[4][4];
if(ob)
Mat4Invert(obinv, ob->obmat);
invert_m4_m4(obinv, ob->obmat);
else
Mat4One(obinv);
unit_m4(obinv);
Mat4MulSerie(result_mat, offset,
mul_serie_m4(result_mat, offset,
obinv, amd->offset_ob->obmat,
NULL, NULL, NULL, NULL, NULL);
Mat4CpyMat4(offset, result_mat);
copy_m4_m4(offset, result_mat);
}
if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
@ -1235,7 +1235,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
float scale;
object_to_mat3(amd->curve_ob, tmp_mat);
scale = Mat3ToScalef(tmp_mat);
scale = mat3_to_scale(tmp_mat);
if(!cu->path) {
cu->flag |= CU_PATH; // needed for path & bevlist
@ -1250,7 +1250,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
prescribed length */
if(amd->fit_type == MOD_ARR_FITLENGTH
|| amd->fit_type == MOD_ARR_FITCURVE) {
float dist = sqrt(Inpf(offset[3], offset[3]));
float dist = sqrt(dot_v3v3(offset[3], offset[3]));
if(dist > 1e-6f)
/* this gives length = first copy start to last copy end
@ -1283,11 +1283,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces, 0, 0);
/* calculate the offset matrix of the final copy (for merging) */
Mat4One(final_offset);
unit_m4(final_offset);
for(j=0; j < count - 1; j++) {
Mat4MulMat4(tmp_mat, final_offset, offset);
Mat4CpyMat4(final_offset, tmp_mat);
mul_m4_m4m4(tmp_mat, final_offset, offset);
copy_m4_m4(final_offset, tmp_mat);
}
numVerts = numEdges = numFaces = 0;
@ -1323,7 +1323,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if((count > 1) && (amd->flags & MOD_ARR_MERGE)) {
float tmp_co[3];
VECCOPY(tmp_co, mv->co);
Mat4MulVecfl(offset, tmp_co);
mul_m4_v3(offset, tmp_co);
for(j = 0; j < maxVerts; j++) {
/* if vertex already merged, don't use it */
@ -1331,15 +1331,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
inMV = &src_mvert[j];
/* if this vert is within merge limit, merge */
if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist)) {
if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) {
indexMap[i].merge = j;
/* test for merging with final copy of merge target */
if(amd->flags & MOD_ARR_MERGEFINAL) {
VECCOPY(tmp_co, inMV->co);
inMV = &src_mvert[i];
Mat4MulVecfl(final_offset, tmp_co);
if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist))
mul_m4_v3(final_offset, tmp_co);
if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist))
indexMap[i].merge_final = 1;
}
break;
@ -1356,7 +1356,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
*mv2 = *mv;
numVerts++;
Mat4MulVecfl(offset, co);
mul_m4_v3(offset, co);
VECCOPY(mv2->co, co);
}
} else if(indexMap[i].merge != i && indexMap[i].merge_final) {
@ -1513,7 +1513,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
cap_medge = start_cap->getEdgeArray(start_cap);
cap_mface = start_cap->getTessFaceArray(start_cap);
Mat4Invert(startoffset, offset);
invert_m4_m4(startoffset, offset);
vert_map = MEM_callocN(sizeof(*vert_map) * capVerts,
"arrayModifier_doArray vert_map");
@ -1529,12 +1529,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
int j;
VECCOPY(tmp_co, mv->co);
Mat4MulVecfl(startoffset, tmp_co);
mul_m4_v3(startoffset, tmp_co);
for(j = 0; j < maxVerts; j++) {
in_mv = &src_mvert[j];
/* if this vert is within merge limit, merge */
if(VecLenCompare(tmp_co, in_mv->co, amd->merge_dist)) {
if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) {
vert_map[i] = calc_mapping(indexMap, j, 0);
merged = 1;
break;
@ -1545,7 +1545,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(!merged) {
DM_copy_vert_data(start_cap, result, i, numVerts, 1);
mvert[numVerts] = *mv;
Mat4MulVecfl(startoffset, mvert[numVerts].co);
mul_m4_v3(startoffset, mvert[numVerts].co);
origindex[numVerts] = ORIGINDEX_NONE;
vert_map[i] = numVerts;
@ -1614,7 +1614,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
cap_medge = end_cap->getEdgeArray(end_cap);
cap_mface = end_cap->getTessFaceArray(end_cap);
Mat4MulMat4(endoffset, final_offset, offset);
mul_m4_m4m4(endoffset, final_offset, offset);
vert_map = MEM_callocN(sizeof(*vert_map) * capVerts,
"arrayModifier_doArray vert_map");
@ -1630,12 +1630,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
int j;
VECCOPY(tmp_co, mv->co);
Mat4MulVecfl(offset, tmp_co);
mul_m4_v3(offset, tmp_co);
for(j = 0; j < maxVerts; j++) {
in_mv = &src_mvert[j];
/* if this vert is within merge limit, merge */
if(VecLenCompare(tmp_co, in_mv->co, amd->merge_dist)) {
if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) {
vert_map[i] = calc_mapping(indexMap, j, count - 1);
merged = 1;
break;
@ -1646,7 +1646,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(!merged) {
DM_copy_vert_data(end_cap, result, i, numVerts, 1);
mvert[numVerts] = *mv;
Mat4MulVecfl(endoffset, mvert[numVerts].co);
mul_m4_v3(endoffset, mvert[numVerts].co);
origindex[numVerts] = ORIGINDEX_NONE;
vert_map[i] = numVerts;
@ -1941,9 +1941,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
if (mmd->mirror_ob) {
float obinv[4][4];
Mat4Invert(obinv, mmd->mirror_ob->obmat);
Mat4MulMat4(mtx, ob->obmat, obinv);
Mat4Invert(imtx, mtx);
invert_m4_m4(obinv, mmd->mirror_ob->obmat);
mul_m4_m4m4(mtx, ob->obmat, obinv);
invert_m4_m4(imtx, mtx);
}
for(i = 0; i < maxVerts; i++) {
@ -1954,10 +1954,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
dm->getVert(dm, i, &inMV);
VecCopyf(co, inMV.co);
copy_v3_v3(co, inMV.co);
if (mmd->mirror_ob) {
VecMat4MulVecfl(co, mtx, co);
mul_v3_m4v3(co, mtx, co);
}
isShared = ABS(co[axis])<=tolerance;
@ -1975,9 +1975,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
if(isShared) {
co[axis] = 0;
if (mmd->mirror_ob) {
VecMat4MulVecfl(co, imtx, co);
mul_v3_m4v3(co, imtx, co);
}
VecCopyf(mv->co, co);
copy_v3_v3(mv->co, co);
mv->flag |= ME_VERT_MERGED;
} else {
@ -1989,9 +1989,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
co[axis] = -co[axis];
if (mmd->mirror_ob) {
VecMat4MulVecfl(co, imtx, co);
mul_v3_m4v3(co, imtx, co);
}
VecCopyf(mv2->co, co);
copy_v3_v3(mv2->co, co);
if (mmd->flag & MOD_MIR_VGROUP){
dvert = DM_get_vert_data(result, numVerts, CD_MDEFORMVERT);
@ -2768,7 +2768,7 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob,
if(texmapping == MOD_DISP_MAP_OBJECT) {
if(dmd->map_object)
Mat4Invert(mapob_imat, dmd->map_object->obmat);
invert_m4_m4(mapob_imat, dmd->map_object->obmat);
else /* if there is no map object, default to local */
texmapping = MOD_DISP_MAP_LOCAL;
}
@ -2834,12 +2834,12 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob,
break;
case MOD_DISP_MAP_GLOBAL:
VECCOPY(*texco, *co);
Mat4MulVecfl(ob->obmat, *texco);
mul_m4_v3(ob->obmat, *texco);
break;
case MOD_DISP_MAP_OBJECT:
VECCOPY(*texco, *co);
Mat4MulVecfl(ob->obmat, *texco);
Mat4MulVecfl(mapob_imat, *texco);
mul_m4_v3(ob->obmat, *texco);
mul_m4_v3(mapob_imat, *texco);
break;
}
}
@ -3110,7 +3110,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* convert coords to world space */
for(i = 0, co = coords; i < numVerts; ++i, ++co)
Mat4MulVecfl(ob->obmat, *co);
mul_m4_v3(ob->obmat, *co);
/* calculate a projection matrix and normal for each projector */
for(i = 0; i < num_projectors; ++i) {
@ -3118,7 +3118,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
float offsetmat[4][4];
Camera *cam = NULL;
/* calculate projection matrix */
Mat4Invert(projectors[i].projmat, projectors[i].ob->obmat);
invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat);
if(projectors[i].ob->type == OB_CAMERA) {
cam = (Camera *)projectors[i].ob->data;
@ -3140,8 +3140,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
xmin = -xmax;
ymin = -ymax;
i_window(xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend, perspmat);
Mat4MulMat4(tmpmat, projectors[i].projmat, perspmat);
perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
mul_m4_m4m4(tmpmat, projectors[i].projmat, perspmat);
} else if(cam->type == CAM_ORTHO) {
float orthomat[4][4];
float xmax;
@ -3159,15 +3159,15 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
xmin = -xmax;
ymin = -ymax;
i_ortho(xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend, orthomat);
Mat4MulMat4(tmpmat, projectors[i].projmat, orthomat);
orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
mul_m4_m4m4(tmpmat, projectors[i].projmat, orthomat);
}
} else {
Mat4CpyMat4(tmpmat, projectors[i].projmat);
copy_m4_m4(tmpmat, projectors[i].projmat);
}
Mat4One(offsetmat);
Mat4MulFloat3(offsetmat[0], 0.5);
unit_m4(offsetmat);
mul_mat3_m4_fl(offsetmat[0], 0.5);
offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5;
if (cam) {
@ -3183,19 +3183,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
}
Mat4MulMat4(projectors[i].projmat, tmpmat, offsetmat);
mul_m4_m4m4(projectors[i].projmat, tmpmat, offsetmat);
/* calculate worldspace projector normal (for best projector test) */
projectors[i].normal[0] = 0;
projectors[i].normal[1] = 0;
projectors[i].normal[2] = 1;
Mat4Mul3Vecfl(projectors[i].ob->obmat, projectors[i].normal);
mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal);
}
/* if only one projector, project coords to UVs */
if(num_projectors == 1)
for(i = 0, co = coords; i < numVerts; ++i, ++co)
Mat4MulVec3Project(projectors[0].projmat, *co);
mul_project_m4_v4(projectors[0].projmat, *co);
mface = dm->getTessFaceArray(dm);
numFaces = dm->getNumTessFaces(dm);
@ -3232,19 +3232,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* get the untransformed face normal */
if(mf->v4) {
VECCOPY(co4, coords[mf->v4]);
CalcNormFloat4(co1, co2, co3, co4, face_no);
normal_quad_v3( face_no,co1, co2, co3, co4);
} else {
CalcNormFloat(co1, co2, co3, face_no);
normal_tri_v3( face_no,co1, co2, co3);
}
/* find the projector which the face points at most directly
* (projector normal with largest dot product is best)
*/
best_dot = Inpf(projectors[0].normal, face_no);
best_dot = dot_v3v3(projectors[0].normal, face_no);
best_projector = &projectors[0];
for(j = 1; j < num_projectors; ++j) {
float tmp_dot = Inpf(projectors[j].normal,
float tmp_dot = dot_v3v3(projectors[j].normal,
face_no);
if(tmp_dot > best_dot) {
best_dot = tmp_dot;
@ -3252,11 +3252,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
}
Mat4MulVec3Project(best_projector->projmat, co1);
Mat4MulVec3Project(best_projector->projmat, co2);
Mat4MulVec3Project(best_projector->projmat, co3);
mul_project_m4_v4(best_projector->projmat, co1);
mul_project_m4_v4(best_projector->projmat, co2);
mul_project_m4_v4(best_projector->projmat, co3);
if(mf->v4)
Mat4MulVec3Project(best_projector->projmat, co4);
mul_project_m4_v4(best_projector->projmat, co4);
/* apply transformed coords as UVs */
tface->uv[0][0] = co1[0];
@ -3552,11 +3552,11 @@ static void smoothModifier_do(
if (uctmp[idx1] < 255) {
uctmp[idx1]++;
VecAddf(v1, v1, fvec);
add_v3_v3v3(v1, v1, fvec);
}
if (uctmp[idx2] < 255) {
uctmp[idx2]++;
VecAddf(v2, v2, fvec);
add_v3_v3v3(v2, v2, fvec);
}
}
@ -3770,14 +3770,14 @@ static void castModifier_sphere_do(
* we use its location, transformed to ob's local space */
if (ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4Invert(ctrl_ob->imat, ctrl_ob->obmat);
Mat4MulMat4(mat, ob->obmat, ctrl_ob->imat);
Mat4Invert(imat, mat);
invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat);
invert_m4_m4(imat, mat);
}
Mat4Invert(ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
VECCOPY(center, ctrl_ob->obmat[3]);
Mat4MulVecfl(ob->imat, center);
mul_m4_v3(ob->imat, center);
}
/* now we check which options the user wants */
@ -3812,7 +3812,7 @@ static void castModifier_sphere_do(
if(len <= 0) {
for (i = 0; i < numVerts; i++) {
len += VecLenf(center, vertexCos[i]);
len += len_v3v3(center, vertexCos[i]);
}
len /= numVerts;
@ -3834,9 +3834,9 @@ static void castModifier_sphere_do(
VECCOPY(tmp_co, vertexCos[i]);
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(mat, tmp_co);
mul_m4_v3(mat, tmp_co);
} else {
VecSubf(tmp_co, tmp_co, center);
sub_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -3846,7 +3846,7 @@ static void castModifier_sphere_do(
vec[2] = 0.0f;
if (has_radius) {
if (VecLength(vec) > cmd->radius) continue;
if (len_v3(vec) > cmd->radius) continue;
}
for (j = 0; j < dvert[i].totweight; ++j) {
@ -3860,7 +3860,7 @@ static void castModifier_sphere_do(
fac = fac_orig * dw->weight;
facm = 1.0f - fac;
Normalize(vec);
normalize_v3(vec);
if (flag & MOD_CAST_X)
tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0];
@ -3871,9 +3871,9 @@ static void castModifier_sphere_do(
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(imat, tmp_co);
mul_m4_v3(imat, tmp_co);
} else {
VecAddf(tmp_co, tmp_co, center);
add_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -3889,9 +3889,9 @@ static void castModifier_sphere_do(
VECCOPY(tmp_co, vertexCos[i]);
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(mat, tmp_co);
mul_m4_v3(mat, tmp_co);
} else {
VecSubf(tmp_co, tmp_co, center);
sub_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -3901,10 +3901,10 @@ static void castModifier_sphere_do(
vec[2] = 0.0f;
if (has_radius) {
if (VecLength(vec) > cmd->radius) continue;
if (len_v3(vec) > cmd->radius) continue;
}
Normalize(vec);
normalize_v3(vec);
if (flag & MOD_CAST_X)
tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0];
@ -3915,9 +3915,9 @@ static void castModifier_sphere_do(
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(imat, tmp_co);
mul_m4_v3(imat, tmp_co);
} else {
VecAddf(tmp_co, tmp_co, center);
add_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -3972,14 +3972,14 @@ static void castModifier_cuboid_do(
if (ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4Invert(ctrl_ob->imat, ctrl_ob->obmat);
Mat4MulMat4(mat, ob->obmat, ctrl_ob->imat);
Mat4Invert(imat, mat);
invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat);
invert_m4_m4(imat, mat);
}
Mat4Invert(ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
VECCOPY(center, ctrl_ob->obmat[3]);
Mat4MulVecfl(ob->imat, center);
mul_m4_v3(ob->imat, center);
}
if((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) {
@ -4008,7 +4008,7 @@ static void castModifier_cuboid_do(
DO_MINMAX(center, min, max);
for (i = 0; i < numVerts; i++) {
VecSubf(vec, vertexCos[i], center);
sub_v3_v3v3(vec, vertexCos[i], center);
DO_MINMAX(vec, min, max);
}
}
@ -4051,9 +4051,9 @@ static void castModifier_cuboid_do(
VECCOPY(tmp_co, vertexCos[i]);
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(mat, tmp_co);
mul_m4_v3(mat, tmp_co);
} else {
VecSubf(tmp_co, tmp_co, center);
sub_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -4089,7 +4089,7 @@ static void castModifier_cuboid_do(
if (tmp_co[2] > 0.0f) octant += 4;
/* apex is the bb's vertex at the chosen octant */
VecCopyf(apex, bb[octant]);
copy_v3_v3(apex, bb[octant]);
/* find which bb plane is closest to this vertex ... */
d[0] = tmp_co[0] / apex[0];
@ -4127,9 +4127,9 @@ static void castModifier_cuboid_do(
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(imat, tmp_co);
mul_m4_v3(imat, tmp_co);
} else {
VecAddf(tmp_co, tmp_co, center);
add_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -4147,9 +4147,9 @@ static void castModifier_cuboid_do(
VECCOPY(tmp_co, vertexCos[i]);
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(mat, tmp_co);
mul_m4_v3(mat, tmp_co);
} else {
VecSubf(tmp_co, tmp_co, center);
sub_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -4164,7 +4164,7 @@ static void castModifier_cuboid_do(
if (tmp_co[1] > 0.0f) octant += 2;
if (tmp_co[2] > 0.0f) octant += 4;
VecCopyf(apex, bb[octant]);
copy_v3_v3(apex, bb[octant]);
d[0] = tmp_co[0] / apex[0];
d[1] = tmp_co[1] / apex[1];
@ -4195,9 +4195,9 @@ static void castModifier_cuboid_do(
if(ctrl_ob) {
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
Mat4MulVecfl(imat, tmp_co);
mul_m4_v3(imat, tmp_co);
} else {
VecAddf(tmp_co, tmp_co, center);
add_v3_v3v3(tmp_co, tmp_co, center);
}
}
@ -4362,7 +4362,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob,
if(texmapping == MOD_WAV_MAP_OBJECT) {
if(wmd->map_object)
Mat4Invert(wmd->map_object->imat, wmd->map_object->obmat);
invert_m4_m4(wmd->map_object->imat, wmd->map_object->obmat);
else /* if there is no map object, default to local */
texmapping = MOD_WAV_MAP_LOCAL;
}
@ -4428,12 +4428,12 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob,
break;
case MOD_WAV_MAP_GLOBAL:
VECCOPY(*texco, *co);
Mat4MulVecfl(ob->obmat, *texco);
mul_m4_v3(ob->obmat, *texco);
break;
case MOD_WAV_MAP_OBJECT:
VECCOPY(*texco, *co);
Mat4MulVecfl(ob->obmat, *texco);
Mat4MulVecfl(wmd->map_object->imat, *texco);
mul_m4_v3(ob->obmat, *texco);
mul_m4_v3(wmd->map_object->imat, *texco);
break;
}
}
@ -4459,8 +4459,8 @@ static void waveModifier_do(WaveModifierData *md,
if(wmd->objectcenter){
float mat[4][4];
/* get the control object's location in local coordinates */
Mat4Invert(ob->imat, ob->obmat);
Mat4MulMat4(mat, wmd->objectcenter->obmat, ob->imat);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_m4m4(mat, wmd->objectcenter->obmat, ob->imat);
wmd->startx = mat[3][0];
wmd->starty = mat[3][1];
@ -4849,14 +4849,14 @@ static void hookModifier_deformVerts(
/* get world-space matrix of target, corrected for the space the verts are in */
if (hmd->subtarget[0] && pchan) {
/* bone target if there's a matching pose-channel */
Mat4MulMat4(dmat, pchan->pose_mat, hmd->object->obmat);
mul_m4_m4m4(dmat, pchan->pose_mat, hmd->object->obmat);
}
else {
/* just object target */
Mat4CpyMat4(dmat, hmd->object->obmat);
copy_m4_m4(dmat, hmd->object->obmat);
}
Mat4Invert(ob->imat, ob->obmat);
Mat4MulSerie(mat, ob->imat, dmat, hmd->parentinv,
invert_m4_m4(ob->imat, ob->obmat);
mul_serie_m4(mat, ob->imat, dmat, hmd->parentinv,
NULL, NULL, NULL, NULL, NULL);
/* vertex indices? */
@ -4886,29 +4886,29 @@ static void hookModifier_deformVerts(
if(orig_index == index) {
co = vertexCos[j];
if(hmd->falloff != 0.0) {
float len = VecLenf(co, hmd->cent);
float len = len_v3v3(co, hmd->cent);
if(len > hmd->falloff) fac = 0.0;
else if(len > 0.0)
fac *= sqrt(1.0 - len / hmd->falloff);
}
if(fac != 0.0) {
VecMat4MulVecfl(vec, mat, co);
VecLerpf(co, co, vec, fac);
mul_v3_m4v3(vec, mat, co);
interp_v3_v3v3(co, co, vec, fac);
}
}
}
} else {
if(hmd->falloff != 0.0) {
float len = VecLenf(co, hmd->cent);
float len = len_v3v3(co, hmd->cent);
if(len > hmd->falloff) fac = 0.0;
else if(len > 0.0)
fac *= sqrt(1.0 - len / hmd->falloff);
}
if(fac != 0.0) {
VecMat4MulVecfl(vec, mat, co);
VecLerpf(co, co, vec, fac);
mul_v3_m4v3(vec, mat, co);
interp_v3_v3v3(co, co, vec, fac);
}
}
}
@ -4947,14 +4947,14 @@ static void hookModifier_deformVerts(
float *co = vertexCos[i];
if(hmd->falloff != 0.0) {
float len = VecLenf(co, hmd->cent);
float len = len_v3v3(co, hmd->cent);
if(len > hmd->falloff) fac = 0.0;
else if(len > 0.0)
fac *= sqrt(1.0 - len / hmd->falloff);
}
VecMat4MulVecfl(vec, mat, co);
VecLerpf(co, co, vec, fac);
mul_v3_m4v3(vec, mat, co);
interp_v3_v3v3(co, co, vec, fac);
}
}
}
@ -5290,7 +5290,7 @@ static void collisionModifier_deformVerts(
for ( i = 0; i < numverts; i++ )
{
// we save global positions
Mat4MulVecfl ( ob->obmat, collmd->x[i].co );
mul_m4_v3( ob->obmat, collmd->x[i].co );
}
collmd->xnew = MEM_dupallocN(collmd->x); // frame end position
@ -5320,7 +5320,7 @@ static void collisionModifier_deformVerts(
for ( i = 0; i < numverts; i++ )
{
// we save global positions
Mat4MulVecfl ( ob->obmat, collmd->xnew[i].co );
mul_m4_v3( ob->obmat, collmd->xnew[i].co );
}
memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert));
@ -5466,14 +5466,14 @@ static void surfaceModifier_deformVerts(
/* convert to global coordinates and calculate velocity */
for(i = 0, x = surmd->x, v = surmd->v; i<numverts; i++, x++, v++) {
vec = CDDM_get_vert(surmd->dm, i)->co;
Mat4MulVecfl(ob->obmat, vec);
mul_m4_v3(ob->obmat, vec);
if(init)
v->co[0] = v->co[1] = v->co[2] = 0.0f;
else
VecSubf(v->co, vec, x->co);
sub_v3_v3v3(v->co, vec, x->co);
VecCopyf(x->co, vec);
copy_v3_v3(x->co, vec);
}
surmd->cfra = md->scene->r.cfra;
@ -5907,7 +5907,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
psys_get_particle_on_path(&sim, first_particle + i/totvert, &state,1);
Normalize(state.vel);
normalize_v3(state.vel);
/* TODO: incremental rotations somehow */
if(state.vel[axis] < -0.9999 || state.vel[axis] > 0.9999) {
@ -5918,10 +5918,10 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
float temp[3] = {0.0f,0.0f,0.0f};
temp[axis] = 1.0f;
Crossf(cross, temp, state.vel);
cross_v3_v3v3(cross, temp, state.vel);
/* state.vel[axis] is the only component surviving from a dot product with the axis */
VecRotToQuat(cross,saacos(state.vel[axis]),state.rot);
axis_angle_to_quat(state.rot,cross,saacos(state.vel[axis]));
}
}
@ -5930,9 +5930,9 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
psys_get_particle_state(&sim, first_particle + i/totvert, &state,1);
}
QuatMulVecf(state.rot,mv->co);
mul_qt_v3(state.rot,mv->co);
if(pimd->flag & eParticleInstanceFlag_UseSize)
VecMulf(mv->co, size[i/totvert]);
mul_v3_fl(mv->co, size[i/totvert]);
VECADD(mv->co,mv->co,state.co);
}
@ -6096,14 +6096,14 @@ static void explodeModifier_createFacepa(ExplodeModifierData *emd,
/* set face-particle-indexes to nearest particle to face center */
for(i=0,fa=mface; i<totface; i++,fa++){
VecAddf(center,mvert[fa->v1].co,mvert[fa->v2].co);
VecAddf(center,center,mvert[fa->v3].co);
add_v3_v3v3(center,mvert[fa->v1].co,mvert[fa->v2].co);
add_v3_v3v3(center,center,mvert[fa->v3].co);
if(fa->v4){
VecAddf(center,center,mvert[fa->v4].co);
VecMulf(center,0.25);
add_v3_v3v3(center,center,mvert[fa->v4].co);
mul_v3_fl(center,0.25);
}
else
VecMulf(center,0.3333f);
mul_v3_fl(center,0.3333f);
p= BLI_kdtree_find_nearest(tree,center,NULL,NULL);
@ -6275,7 +6275,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive
mv=CDDM_get_vert(splitdm,i);
VECADD(dupve->co,dupve->co,mv->co);
VecMulf(dupve->co,0.5);
mul_v3_fl(dupve->co,0.5);
}
BLI_edgehashIterator_free(ehi);
@ -6491,7 +6491,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive
VECADD(dupve->co,dupve->co,mv->co);
mv=CDDM_get_vert(splitdm,mf->v4);
VECADD(dupve->co,dupve->co,mv->co);
VecMulf(dupve->co,0.25);
mul_v3_fl(dupve->co,0.25);
df1=CDDM_get_tessface(splitdm,curdupface);
@ -6668,7 +6668,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
/*dupvert= CDDM_get_verts(explode);*/
/* getting back to object space */
Mat4Invert(imat,ob->obmat);
invert_m4_m4(imat,ob->obmat);
psmd->psys->lattice = psys_get_lattice(&sim);
@ -6695,23 +6695,23 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
/* get particle state */
psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,0,0,0,0);
Mat4MulVecfl(ob->obmat,loc0);
mul_m4_v3(ob->obmat,loc0);
state.time=cfra;
psys_get_particle_state(&sim, i, &state, 1);
vertco=CDDM_get_vert(explode,v)->co;
Mat4MulVecfl(ob->obmat,vertco);
mul_m4_v3(ob->obmat,vertco);
VECSUB(vertco,vertco,loc0);
/* apply rotation, size & location */
QuatMulVecf(state.rot,vertco);
VecMulf(vertco,pa->size);
mul_qt_v3(state.rot,vertco);
mul_v3_fl(vertco,pa->size);
VECADD(vertco,vertco,state.co);
Mat4MulVecfl(imat,vertco);
mul_m4_v3(imat,vertco);
}
}
BLI_edgehashIterator_free(ehi);
@ -7078,11 +7078,11 @@ static void meshdeformModifier_do(
return;
/* compute matrices to go in and out of cage object space */
Mat4Invert(imat, mmd->object->obmat);
Mat4MulMat4(cagemat, ob->obmat, imat);
Mat4MulMat4(cmat, cagemat, mmd->bindmat);
Mat4Invert(iobmat, cmat);
Mat3CpyMat4(icagemat, iobmat);
invert_m4_m4(imat, mmd->object->obmat);
mul_m4_m4m4(cagemat, ob->obmat, imat);
mul_m4_m4m4(cmat, cagemat, mmd->bindmat);
invert_m4_m4(iobmat, cmat);
copy_m3_m4(icagemat, iobmat);
/* bind weights if needed */
if(!mmd->bindcos) {
@ -7116,7 +7116,7 @@ static void meshdeformModifier_do(
VECCOPY(co, cagemvert[a].co);
if(G.rt != 527) {
Mat4MulVecfl(mmd->bindmat, co);
mul_m4_v3(mmd->bindmat, co);
/* compute difference with world space bind coord */
VECSUB(dco[a], co, bindcos[a]);
}
@ -7170,7 +7170,7 @@ static void meshdeformModifier_do(
if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
/* transform coordinate into cage's local space */
VECCOPY(co, vertexCos[b]);
Mat4MulVecfl(cagemat, co);
mul_m4_v3(cagemat, co);
totweight= meshdeform_dynamic_bind(mmd, dco, co);
}
else {
@ -7187,8 +7187,8 @@ static void meshdeformModifier_do(
}
if(totweight > 0.0f) {
VecMulf(co, fac/totweight);
Mat3MulVecfl(icagemat, co);
mul_v3_fl(co, fac/totweight);
mul_m3_v3(icagemat, co);
if(G.rt != 527)
VECADD(vertexCos[b], vertexCos[b], co)
else
@ -7279,7 +7279,7 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob,
int i;
MVert *dst = CDDM_get_verts(final);
for(i = 0; i < mmd->undo_verts_tot; ++i) {
VecCopyf(dst[i].co, mmd->undo_verts[i].co);
copy_v3_v3(dst[i].co, mmd->undo_verts[i].co);
}
CDDM_calc_normals(final);
@ -7560,10 +7560,10 @@ static void shapekeyModifier_deformMatricesEM(
int a;
if(kb && kb->totelem==numVerts && kb!=key->refkey) {
Mat3Scale(scale, kb->curval);
scale_m3_fl(scale, kb->curval);
for(a=0; a<numVerts; a++)
Mat3CpyMat3(defMats[a], scale);
copy_m3_m3(defMats[a], scale);
}
}

@ -36,7 +36,7 @@
#include "float.h"
#include "ctype.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_kdopbvh.h"
#include "BLI_kdtree.h"
@ -422,13 +422,13 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(amd->end_cap && amd->end_cap != ob)
end_cap = mesh_get_derived_final(scene, amd->end_cap, CD_MASK_MESH);
Mat4One(offset);
unit_m4(offset);
src_mvert = cddm->getVertArray(dm);
maxVerts = cddm->getNumVerts(dm);
if(amd->offset_type & MOD_ARR_OFF_CONST)
VecAddf(offset[3], offset[3], amd->offset);
add_v3_v3v3(offset[3], offset[3], amd->offset);
if(amd->offset_type & MOD_ARR_OFF_RELATIVE) {
for(j = 0; j < 3; j++)
offset[3][j] += amd->scale[j] * vertarray_size(src_mvert,
@ -440,14 +440,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
float result_mat[4][4];
if(ob)
Mat4Invert(obinv, ob->obmat);
invert_m4_m4(obinv, ob->obmat);
else
Mat4One(obinv);
unit_m4(obinv);
Mat4MulSerie(result_mat, offset,
mul_serie_m4(result_mat, offset,
obinv, amd->offset_ob->obmat,
NULL, NULL, NULL, NULL, NULL);
Mat4CpyMat4(offset, result_mat);
copy_m4_m4(offset, result_mat);
}
if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
@ -457,7 +457,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
float scale;
object_to_mat3(amd->curve_ob, tmp_mat);
scale = Mat3ToScalef(tmp_mat);
scale = mat3_to_scale(tmp_mat);
if(!cu->path) {
cu->flag |= CU_PATH; // needed for path & bevlist
@ -505,11 +505,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
}
/* calculate the offset matrix of the final copy (for merging) */
Mat4One(final_offset);
unit_m4(final_offset);
for(j=0; j < count - 1; j++) {
Mat4MulMat4(tmp_mat, final_offset, offset);
Mat4CpyMat4(final_offset, tmp_mat);
mul_m4_m4m4(tmp_mat, final_offset, offset);
copy_m4_m4(final_offset, tmp_mat);
}
BMO_Init_Op(&weldop, "weldverts");
@ -670,10 +670,10 @@ DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
if (mmd->mirror_ob) {
float mtx2[4][4], vec[3];
Mat4Invert(mtx2, mmd->mirror_ob->obmat);
Mat4MulMat4(mtx, ob->obmat, mtx2);
invert_m4_m4(mtx2, mmd->mirror_ob->obmat);
mul_m4_m4m4(mtx, ob->obmat, mtx2);
} else {
Mat4One(mtx);
unit_m4(mtx);
}
BMO_InitOpf(bm, &op, "mirror geom=%avef mat=%m4 mergedist=%f axis=%d",

@ -37,7 +37,7 @@
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BKE_cdderivedmesh.h"
@ -164,7 +164,7 @@ int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src
int i;
for(i = 0; i < src_me->totvert; ++i)
VecCopyf(mvert[i].co, src_me->mvert[i].co);
copy_v3_v3(mvert[i].co, src_me->mvert[i].co);
mrdm->needsFree = 1;
MultiresDM_mark_as_modified(mrdm);
mrdm->release(mrdm);
@ -178,9 +178,9 @@ int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src
static void Mat3FromColVecs(float mat[][3], float v1[3], float v2[3], float v3[3])
{
VecCopyf(mat[0], v1);
VecCopyf(mat[1], v2);
VecCopyf(mat[2], v3);
copy_v3_v3(mat[0], v1);
copy_v3_v3(mat[1], v2);
copy_v3_v3(mat[2], v3);
}
static DerivedMesh *multires_subdisp_pre(DerivedMesh *mrdm, int distance, int simple)
@ -233,7 +233,7 @@ static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final,
if(!addverts) {
for(i = 0; i < totvert; ++i) {
float z[3] = {0,0,0};
VecCopyf(mvd[i].co, z);
copy_v3_v3(mvd[i].co, z);
}
}
@ -424,7 +424,7 @@ void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Object
for(j = 0, y = 0; y < st; y += skip) {
for(x = 0; x < st; x += skip) {
VecCopyf(disps[j], mdisps[i].disps[y * st + x]);
copy_v3_v3(disps[j], mdisps[i].disps[y * st + x]);
++j;
}
}
@ -998,27 +998,27 @@ static void calc_disp_mat(MultiresDisplacer *d, float mat[3][3])
if(u < 0) {
u = multires_index_at_loc(d->face_index, d->x - 1, d->y, d, &d->edges_primary);
VecSubf(t1, base->co, d->subco[u].co);
sub_v3_v3v3(t1, base->co, d->subco[u].co);
}
else
VecSubf(t1, d->subco[u].co, base->co);
sub_v3_v3v3(t1, d->subco[u].co, base->co);
if(v < 0) {
v = multires_index_at_loc(d->face_index, d->x, d->y - 1, d, &d->edges_primary);
VecSubf(t2, base->co, d->subco[v].co);
sub_v3_v3v3(t2, base->co, d->subco[v].co);
}
else
VecSubf(t2, d->subco[v].co, base->co);
sub_v3_v3v3(t2, d->subco[v].co, base->co);
//printf("uu=%d, vv=%d\n", u, v);
Normalize(t1);
Normalize(t2);
normalize_v3(t1);
normalize_v3(t2);
Mat3FromColVecs(mat, t1, t2, norm);
if(d->invert) {
Mat3Inv(inv, mat);
Mat3CpyMat3(mat, inv);
invert_m3_m3(inv, mat);
copy_m3_m3(mat, inv);
}
}
@ -1033,23 +1033,23 @@ static void multires_displace(MultiresDisplacer *d, float co[3])
data = d->grid->disps[(d->y * d->spacing) * d->disp_st + (d->x * d->spacing)];
if(d->invert)
VecSubf(disp, co, subco->co);
sub_v3_v3v3(disp, co, subco->co);
else
VecCopyf(disp, data);
copy_v3_v3(disp, data);
/* Apply ts matrix to displacement */
calc_disp_mat(d, mat);
Mat3MulVecfl(mat, disp);
mul_m3_v3(mat, disp);
if(d->invert) {
VecCopyf(data, disp);
copy_v3_v3(data, disp);
}
else {
if(d->type == 4 || d->type == 5)
VecMulf(disp, d->weight);
VecAddf(co, co, disp);
mul_v3_fl(disp, d->weight);
add_v3_v3v3(co, co, disp);
}
if(d->type == 2) {
@ -1200,7 +1200,7 @@ static void multiresModifier_update(DerivedMesh *dm)
/* Subtract the original vertex cos from the new vertex cos */
verts_new = CDDM_get_verts(dm);
for(i = 0; i < dm->getNumVerts(dm); ++i)
VecSubf(verts_new[i].co, verts_new[i].co, cur_lvl_orig_verts[i].co);
sub_v3_v3v3(verts_new[i].co, verts_new[i].co, cur_lvl_orig_verts[i].co);
final = multires_subdisp_pre(dm, totlvl - lvl, 0);
@ -1579,7 +1579,7 @@ void multires_load_old(DerivedMesh *dm, Multires *mr)
/* Transfer verts */
for(i = 0; i < totvert; ++i)
VecCopyf(vdst[i].co, vsrc[vvmap[i]].co);
copy_v3_v3(vdst[i].co, vsrc[vvmap[i]].co);
MEM_freeN(vvmap);
}

@ -53,7 +53,7 @@
#include "BKE_text.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_rand.h"
#include "BLI_threads.h"

@ -70,7 +70,7 @@
#include "DNA_world_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BKE_utildefines.h"
@ -741,13 +741,13 @@ float dof_camera(Object *ob)
return 0.0f;
if (cam->dof_ob) {
/* too simple, better to return the distance on the view axis only
* return VecLenf(ob->obmat[3], cam->dof_ob->obmat[3]); */
* return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */
float mat[4][4], obmat[4][4];
Mat4CpyMat4(obmat, ob->obmat);
Mat4Ortho(obmat);
Mat4Invert(ob->imat, obmat);
Mat4MulMat4(mat, cam->dof_ob->obmat, ob->imat);
copy_m4_m4(obmat, ob->obmat);
normalize_m4(obmat);
invert_m4_m4(ob->imat, obmat);
mul_m4_m4m4(mat, cam->dof_ob->obmat, ob->imat);
return (float)fabs(mat[3][2]);
}
return cam->YF_dofdist;
@ -966,8 +966,8 @@ Object *add_only_object(int type, char *name)
/* ob->transflag= OB_QUAT; */
#if 0 /* not used yet */
QuatOne(ob->quat);
QuatOne(ob->dquat);
unit_qt(ob->quat);
unit_qt(ob->dquat);
#endif
ob->col[0]= ob->col[1]= ob->col[2]= 1.0;
@ -977,9 +977,9 @@ Object *add_only_object(int type, char *name)
ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0;
ob->size[0]= ob->size[1]= ob->size[2]= 1.0;
Mat4One(ob->constinv);
Mat4One(ob->parentinv);
Mat4One(ob->obmat);
unit_m4(ob->constinv);
unit_m4(ob->parentinv);
unit_m4(ob->obmat);
ob->dt= OB_SHADED;
ob->empty_drawtype= OB_ARROWS;
ob->empty_drawsize= 1.0;
@ -1465,7 +1465,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
}
ob->parent= target->parent; /* libdata */
Mat4CpyMat4(ob->parentinv, target->parentinv);
copy_m4_m4(ob->parentinv, target->parentinv);
/* copy animdata stuff - drivers only for now... */
if ((target->adt) && (target->adt->drivers.first)) {
@ -1589,7 +1589,7 @@ void object_scale_to_mat3(Object *ob, float mat[][3])
vec[0]= ob->size[0]+ob->dsize[0];
vec[1]= ob->size[1]+ob->dsize[1];
vec[2]= ob->size[2]+ob->dsize[2];
SizeToMat3(vec, mat);
size_to_mat3( mat,vec);
}
// TODO: this should take rotation orders into account later...
@ -1600,29 +1600,29 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
/* initialise the delta-rotation matrix, which will get (pre)multiplied
* with the rotation matrix to yield the appropriate rotation
*/
Mat3One(dmat);
unit_m3(dmat);
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (ob->rotmode > 0) {
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
EulOToMat3(ob->rot, ob->rotmode, rmat);
EulOToMat3(ob->drot, ob->rotmode, dmat);
eulO_to_mat3( rmat,ob->rot, ob->rotmode);
eulO_to_mat3( dmat,ob->drot, ob->rotmode);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
/* axis-angle - not really that great for 3D-changing orientations */
AxisAngleToMat3(ob->rotAxis, ob->rotAngle, rmat);
AxisAngleToMat3(ob->drotAxis, ob->drotAngle, dmat);
axis_angle_to_mat3( rmat,ob->rotAxis, ob->rotAngle);
axis_angle_to_mat3( dmat,ob->drotAxis, ob->drotAngle);
}
else {
/* quats are normalised before use to eliminate scaling issues */
NormalQuat(ob->quat);
QuatToMat3(ob->quat, rmat);
QuatToMat3(ob->dquat, dmat);
normalize_qt(ob->quat);
quat_to_mat3( rmat,ob->quat);
quat_to_mat3( dmat,ob->dquat);
}
/* combine these rotations */
// XXX is this correct? if errors, change the order of multiplication...
Mat3MulMat3(mat, dmat, rmat);
mul_m3_m3m3(mat, dmat, rmat);
}
void object_to_mat3(Object *ob, float mat[][3]) /* no parent */
@ -1636,7 +1636,7 @@ void object_to_mat3(Object *ob, float mat[][3]) /* no parent */
/* rot */
object_rot_to_mat3(ob, rmat);
Mat3MulMat3(mat, rmat, smat);
mul_m3_m3m3(mat, rmat, smat);
}
void object_to_mat4(Object *ob, float mat[][4])
@ -1645,7 +1645,7 @@ void object_to_mat4(Object *ob, float mat[][4])
object_to_mat3(ob, tmat);
Mat4CpyMat3(mat, tmat);
copy_m4_m3(mat, tmat);
mat[3][0]= ob->loc[0] + ob->dloc[0];
mat[3][1]= ob->loc[1] + ob->dloc[1];
@ -1660,7 +1660,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
float q[4], vec[4], dir[3], quat[4], radius, x1, ctime;
float timeoffs = 0.0, sf_orig = 0.0;
Mat4One(mat);
unit_m4(mat);
cu= par->data;
if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
@ -1708,25 +1708,25 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) {
if(cu->flag & CU_FOLLOW) {
vectoquat(dir, ob->trackflag, ob->upflag, quat);
vec_to_quat( quat,dir, ob->trackflag, ob->upflag);
/* the tilt */
Normalize(dir);
normalize_v3(dir);
q[0]= (float)cos(0.5*vec[3]);
x1= (float)sin(0.5*vec[3]);
q[1]= -x1*dir[0];
q[2]= -x1*dir[1];
q[3]= -x1*dir[2];
QuatMul(quat, q, quat);
mul_qt_qtqt(quat, q, quat);
QuatToMat4(quat, mat);
quat_to_mat4( mat,quat);
}
if(cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
Mat4Scale(tmat, radius);
Mat4MulMat4(rmat, mat, tmat);
Mat4CpyMat4(mat, rmat);
scale_m4_fl(tmat, radius);
mul_m4_m4m4(rmat, mat, tmat);
copy_m4_m4(mat, rmat);
}
VECCOPY(mat[3], vec);
@ -1740,7 +1740,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
float vec[3];
if (par->type!=OB_ARMATURE) {
Mat4One(mat);
unit_m4(mat);
return;
}
@ -1748,17 +1748,17 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
pchan= get_pose_channel(par->pose, ob->parsubstr);
if (!pchan){
printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr);
Mat4One(mat);
unit_m4(mat);
return;
}
/* get bone transform */
Mat4CpyMat4(mat, pchan->pose_mat);
copy_m4_m4(mat, pchan->pose_mat);
/* but for backwards compatibility, the child has to move to the tail */
VECCOPY(vec, mat[1]);
VecMulf(vec, pchan->bone->length);
VecAddf(mat[3], mat[3], vec);
mul_v3_fl(vec, pchan->bone->length);
add_v3_v3v3(mat[3], mat[3], vec);
}
static void give_parvert(Object *par, int nr, float *vec)
@ -1795,7 +1795,7 @@ static void give_parvert(Object *par, int nr, float *vec)
for(i = 0; i < numVerts; ++i, ++index) {
if(*index == nr) {
dm->getVertCo(dm, i, co);
VecAddf(vec, vec, co);
add_v3_v3v3(vec, vec, co);
count++;
}
}
@ -1803,7 +1803,7 @@ static void give_parvert(Object *par, int nr, float *vec)
if (count==0) {
/* keep as 0,0,0 */
} else if(count > 0) {
VecMulf(vec, 1.0f / count);
mul_v3_fl(vec, 1.0f / count);
} else {
/* use first index if its out of range */
dm->getVertCo(dm, 0, vec);
@ -1887,7 +1887,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
float cmat[3][3], v1[3], v2[3], v3[3], q[4];
/* in local ob space */
Mat4One(mat);
unit_m4(mat);
if (ELEM4(par->type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE)) {
@ -1895,17 +1895,17 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
give_parvert(par, ob->par2, v2);
give_parvert(par, ob->par3, v3);
triatoquat(v1, v2, v3, q);
QuatToMat3(q, cmat);
Mat4CpyMat3(mat, cmat);
tri_to_quat( q,v1, v2, v3);
quat_to_mat3( cmat,q);
copy_m4_m3(mat, cmat);
if(ob->type==OB_CURVE) {
VECCOPY(mat[3], v1);
}
else {
VecAddf(mat[3], v1, v2);
VecAddf(mat[3], mat[3], v3);
VecMulf(mat[3], 0.3333333f);
add_v3_v3v3(mat[3], v1, v2);
add_v3_v3v3(mat[3], mat[3], v3);
mul_v3_fl(mat[3], 0.3333333f);
}
}
}
@ -1993,8 +1993,8 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
}
/* set negative scale flag in object */
Crossf(vec, ob->obmat[0], ob->obmat[1]);
if( Inpf(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE;
cross_v3_v3v3(vec, ob->obmat[0], ob->obmat[1]);
if( dot_v3v3(vec, ob->obmat[2]) < 0.0 ) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
}
@ -2008,7 +2008,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
object_to_mat4(ob, locmat);
if(ob->partype & PARSLOW) Mat4CpyMat4(slowmat, obmat);
if(ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
switch(ob->partype & PARTYPE) {
case PAROBJECT:
@ -2020,43 +2020,43 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
}
}
if(ok) Mat4MulSerie(totmat, par->obmat, tmat,
if(ok) mul_serie_m4(totmat, par->obmat, tmat,
NULL, NULL, NULL, NULL, NULL, NULL);
else Mat4CpyMat4(totmat, par->obmat);
else copy_m4_m4(totmat, par->obmat);
break;
case PARBONE:
ob_parbone(ob, par, tmat);
Mat4MulSerie(totmat, par->obmat, tmat,
mul_serie_m4(totmat, par->obmat, tmat,
NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PARVERT1:
Mat4One(totmat);
unit_m4(totmat);
if (simul){
VECCOPY(totmat[3], par->obmat[3]);
}
else{
give_parvert(par, ob->par1, vec);
VecMat4MulVecfl(totmat[3], par->obmat, vec);
mul_v3_m4v3(totmat[3], par->obmat, vec);
}
break;
case PARVERT3:
ob_parvert3(ob, par, tmat);
Mat4MulSerie(totmat, par->obmat, tmat,
mul_serie_m4(totmat, par->obmat, tmat,
NULL, NULL, NULL, NULL, NULL, NULL);
break;
case PARSKEL:
Mat4CpyMat4(totmat, par->obmat);
copy_m4_m4(totmat, par->obmat);
break;
}
// total
Mat4MulSerie(tmat, totmat, ob->parentinv,
mul_serie_m4(tmat, totmat, ob->parentinv,
NULL, NULL, NULL, NULL, NULL, NULL);
Mat4MulSerie(obmat, tmat, locmat,
mul_serie_m4(obmat, tmat, locmat,
NULL, NULL, NULL, NULL, NULL, NULL);
if (simul) {
@ -2064,7 +2064,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
}
else{
// external usable originmat
Mat3CpyMat4(originmat, tmat);
copy_m3_m4(originmat, tmat);
// origin, voor help line
if( (ob->partype & 15)==PARSKEL ) {
@ -2083,9 +2083,9 @@ void solve_tracking (Object *ob, float targetmat[][4])
float totmat[3][3];
float tmat[4][4];
VecSubf(vec, ob->obmat[3], targetmat[3]);
vectoquat(vec, ob->trackflag, ob->upflag, quat);
QuatToMat3(quat, totmat);
sub_v3_v3v3(vec, ob->obmat[3], targetmat[3]);
vec_to_quat( quat,vec, ob->trackflag, ob->upflag);
quat_to_mat3( totmat,quat);
if(ob->parent && (ob->transflag & OB_POWERTRACK)) {
/* 'temporal' : clear parent info */
@ -2098,9 +2098,9 @@ void solve_tracking (Object *ob, float targetmat[][4])
tmat[3][2]= ob->obmat[3][2];
tmat[3][3]= ob->obmat[3][3];
}
else Mat4CpyMat4(tmat, ob->obmat);
else copy_m4_m4(tmat, ob->obmat);
Mat4MulMat34(ob->obmat, totmat, tmat);
mul_m4_m3m4(ob->obmat, totmat, tmat);
}
@ -2172,9 +2172,9 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob)
{
clear_workob(workob);
Mat4One(workob->obmat);
Mat4One(workob->parentinv);
Mat4One(workob->constinv);
unit_m4(workob->obmat);
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
workob->parent= ob->parent;
workob->track= ob->track;
@ -2262,7 +2262,7 @@ void minmax_object(Object *ob, float *min, float *max)
bb= *(cu->bb);
for(a=0; a<8; a++) {
Mat4MulVecfl(ob->obmat, bb.vec[a]);
mul_m4_v3(ob->obmat, bb.vec[a]);
DO_MINMAX(bb.vec[a], min, max);
}
break;
@ -2271,10 +2271,10 @@ void minmax_object(Object *ob, float *min, float *max)
bPoseChannel *pchan;
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
VECCOPY(vec, pchan->pose_head);
Mat4MulVecfl(ob->obmat, vec);
mul_m4_v3(ob->obmat, vec);
DO_MINMAX(vec, min, max);
VECCOPY(vec, pchan->pose_tail);
Mat4MulVecfl(ob->obmat, vec);
mul_m4_v3(ob->obmat, vec);
DO_MINMAX(vec, min, max);
}
break;
@ -2287,7 +2287,7 @@ void minmax_object(Object *ob, float *min, float *max)
bb = *mesh_get_bb(ob);
for(a=0; a<8; a++) {
Mat4MulVecfl(ob->obmat, bb.vec[a]);
mul_m4_v3(ob->obmat, bb.vec[a]);
DO_MINMAX(bb.vec[a], min, max);
}
}
@ -2299,11 +2299,11 @@ void minmax_object(Object *ob, float *min, float *max)
DO_MINMAX(ob->obmat[3], min, max);
VECCOPY(vec, ob->obmat[3]);
VecAddf(vec, vec, ob->size);
add_v3_v3v3(vec, vec, ob->size);
DO_MINMAX(vec, min, max);
VECCOPY(vec, ob->obmat[3]);
VecSubf(vec, vec, ob->size);
sub_v3_v3v3(vec, vec, ob->size);
DO_MINMAX(vec, min, max);
break;
}
@ -2354,11 +2354,11 @@ void object_handle_update(Scene *scene, Object *ob)
// printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
if(ob->proxy_from->proxy_group) {/* transform proxy into group space */
Object *obg= ob->proxy_from->proxy_group;
Mat4Invert(obg->imat, obg->obmat);
Mat4MulMat4(ob->obmat, ob->proxy_from->obmat, obg->imat);
invert_m4_m4(obg->imat, obg->obmat);
mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat);
}
else
Mat4CpyMat4(ob->obmat, ob->proxy_from->obmat);
copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
}
else
where_is_object(scene, ob);
@ -2538,7 +2538,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
v1 = triangle_indexes[i][0];
v2 = triangle_indexes[i][1];
v3 = triangle_indexes[i][2];
result = RayIntersectsTriangle(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL);
result = isect_ray_tri_v3(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL);
}
return result;

@ -51,7 +51,7 @@
#include "DNA_smoke_types.h"
#include "DNA_texture_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
#include "BLI_kdtree.h"
@ -619,12 +619,12 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo
/* transform to view space */
VECCOPY(co, center);
co[3]= 1.0f;
Mat4MulVec4fl(data->viewmat, co);
mul_m4_v4(data->viewmat, co);
/* compute two vectors orthogonal to view vector */
VECCOPY(view, co);
Normalize(view);
VecOrthoBasisf(view, ortho1, ortho2);
normalize_v3(view);
ortho_basis_v3v3_v3( ortho1, ortho2,view);
/* compute on screen minification */
w= co[2]*data->winmat[2][3] + data->winmat[3][3];
@ -638,7 +638,7 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo
/* viewport of the screen test */
/* project point on screen */
Mat4MulVec4fl(data->winmat, co);
mul_m4_v4(data->winmat, co);
if(co[3] != 0.0f) {
co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]);
co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]);
@ -699,9 +699,9 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
psys->pathcachebufs.first = psys->pathcachebufs.last = NULL;
psys->childcachebufs.first = psys->childcachebufs.last = NULL;
Mat4CpyMat4(data->winmat, winmat);
Mat4MulMat4(data->viewmat, ob->obmat, viewmat);
Mat4MulMat4(data->mat, data->viewmat, winmat);
copy_m4_m4(data->winmat, winmat);
mul_m4_m4m4(data->viewmat, ob->obmat, viewmat);
mul_m4_m4m4(data->mat, data->viewmat, winmat);
data->winx= winx;
data->winy= winy;
@ -829,11 +829,11 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
if(mf->v4) {
VECCOPY(co4, mvert[mf->v4].co);
VECADD(facecenter[b], facecenter[b], co4);
facearea[b] += AreaQ3Dfl(co1, co2, co3, co4);
facearea[b] += area_quad_v3(co1, co2, co3, co4);
facetotvert[b] += 4;
}
else {
facearea[b] += AreaT3Dfl(co1, co2, co3);
facearea[b] += area_tri_v3(co1, co2, co3);
facetotvert[b] += 3;
}
}
@ -841,7 +841,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
for(a=0; a<totorigface; a++)
if(facetotvert[a] > 0)
VecMulf(facecenter[a], 1.0f/facetotvert[a]);
mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]);
/* for conversion from BU area / pixel area to reference screen size */
mesh_get_texspace(me, 0, 0, size);
@ -1008,7 +1008,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic
float t[4];
if(type<0) {
VecfCubicInterpol(keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt, result->co, result->vel);
interp_cubic_v3( result->co, result->vel,keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt);
}
else {
key_curve_position_weights(dt, t, type);
@ -1281,9 +1281,9 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
/* convert velocity to timestep size */
if(pind->keyed || pind->cache || point_vel){
VecMulf(keys[1].vel, dfra / frs_sec);
VecMulf(keys[2].vel, dfra / frs_sec);
QuatInterpol(result->rot,keys[1].rot,keys[2].rot,keytime);
mul_v3_fl(keys[1].vel, dfra / frs_sec);
mul_v3_fl(keys[2].vel, dfra / frs_sec);
interp_qt_qtqt(result->rot,keys[1].rot,keys[2].rot,keytime);
}
/* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/
@ -1293,7 +1293,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
/* the velocity needs to be converted back from cubic interpolation */
if(pind->keyed || pind->cache || point_vel)
VecMulf(result->vel, frs_sec / dfra);
mul_v3_fl(result->vel, frs_sec / dfra);
}
/************************************************/
/* Particles on a dm */
@ -1313,14 +1313,14 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
VECCOPY(n1,(mvert+mface->v1)->no);
VECCOPY(n2,(mvert+mface->v2)->no);
VECCOPY(n3,(mvert+mface->v3)->no);
Normalize(n1);
Normalize(n2);
Normalize(n3);
normalize_v3(n1);
normalize_v3(n2);
normalize_v3(n3);
if(mface->v4) {
v4= (mvert+mface->v4)->co;
VECCOPY(n4,(mvert+mface->v4)->no);
Normalize(n4);
normalize_v3(n4);
vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0] + w[3]*v4[0];
vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1] + w[3]*v4[1];
@ -1333,7 +1333,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2] + w[3]*n4[2];
}
else
CalcNormFloat4(v1,v2,v3,v4,nor);
normal_quad_v3(nor,v1,v2,v3,v4);
}
}
else {
@ -1348,7 +1348,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2];
}
else
CalcNormFloat(v1,v2,v3,nor);
normal_tri_v3(nor,v1,v2,v3);
}
}
@ -1362,11 +1362,11 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
}
else{
uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3];
spheremap(v1[0], v1[1], v1[2], uv1, uv1+1);
spheremap(v2[0], v2[1], v2[2], uv2, uv2+1);
spheremap(v3[0], v3[1], v3[2], uv3, uv3+1);
map_to_sphere( uv1, uv1+1,v1[0], v1[1], v1[2]);
map_to_sphere( uv2, uv2+1,v2[0], v2[1], v2[2]);
map_to_sphere( uv3, uv3+1,v3[0], v3[1], v3[2]);
if(v4)
spheremap(v4[0], v4[1], v4[2], uv4, uv4+1);
map_to_sphere( uv4, uv4+1,v4[0], v4[1], v4[2]);
}
if(v4){
@ -1376,8 +1376,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
t1= uv3[1] - uv1[1];
t2= uv4[1] - uv1[1];
VecSubf(e1, v3, v1);
VecSubf(e2, v4, v1);
sub_v3_v3v3(e1, v3, v1);
sub_v3_v3v3(e2, v4, v1);
}
else{
s1= uv2[0] - uv1[0];
@ -1386,8 +1386,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
t1= uv2[1] - uv1[1];
t2= uv3[1] - uv1[1];
VecSubf(e1, v2, v1);
VecSubf(e2, v3, v1);
sub_v3_v3v3(e1, v2, v1);
sub_v3_v3v3(e2, v3, v1);
}
vtan[0] = (s1*e2[0] - s2*e1[0]);
@ -1412,7 +1412,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2] + w[3]*o4[2];
if(ornor)
CalcNormFloat4(o1, o2, o3, o4, ornor);
normal_quad_v3( ornor,o1, o2, o3, o4);
}
else {
orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0];
@ -1420,7 +1420,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2];
if(ornor)
CalcNormFloat(o1, o2, o3, ornor);
normal_tri_v3( ornor,o1, o2, o3);
}
}
else {
@ -1518,10 +1518,10 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, float *w, float
if(quad) {
v[3][0]= osface->uv[3][0]; v[3][1]= osface->uv[3][1]; v[3][2]= 0.0f;
MeanValueWeights(v, 4, co, neww);
interp_weights_poly_v3( neww,v, 4, co);
}
else {
MeanValueWeights(v, 3, co, neww);
interp_weights_poly_v3( neww,v, 3, co);
neww[3]= 0.0f;
}
}
@ -1567,10 +1567,10 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float *
/* check that this intersects - Its possible this misses :/ -
* could also check its not between */
if(quad) {
if(IsectPQ2Df(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
return findex;
}
else if(IsectPT2Df(uv, faceuv[0], faceuv[1], faceuv[2]))
else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2]))
return findex;
}
}
@ -1583,10 +1583,10 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float *
/* check that this intersects - Its possible this misses :/ -
* could also check its not between */
if(quad) {
if(IsectPQ2Df(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
return findex;
}
else if(IsectPT2Df(uv, faceuv[0], faceuv[1], faceuv[2]))
else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2]))
return findex;
}
}
@ -1679,7 +1679,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache
if(nor) {
dm->getVertNo(dm,mapindex,nor);
Normalize(nor);
normalize_v3(nor);
}
if(orco)
@ -1687,7 +1687,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache
if(ornor) {
dm->getVertNo(dm,mapindex,nor);
Normalize(nor);
normalize_v3(nor);
}
if(utan && vtan) {
@ -1712,8 +1712,8 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache
if(nor)
VECCOPY(nor,tmpnor);
Normalize(tmpnor);
VecMulf(tmpnor,-foffset);
normalize_v3(tmpnor);
mul_v3_fl(tmpnor,-foffset);
VECADD(vec,vec,tmpnor);
}
else
@ -1836,42 +1836,42 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo
if(par_rot)
QUATCOPY(q2,par_rot)
else
vectoquat(par->vel,axis,(axis+1)%3, q2);
QuatMulVecf(q2,vec);
VecMulf(vec,amplitude);
vec_to_quat( q2,par->vel,axis,(axis+1)%3);
mul_qt_v3(q2,vec);
mul_v3_fl(vec,amplitude);
VECADD(state->co,state->co,vec);
VECSUB(vec,state->co,par->co);
if(t!=0.0)
VecRotToQuat(par->vel,t,q1);
axis_angle_to_quat(q1,par->vel,t);
QuatMulVecf(q1,vec);
mul_qt_v3(q1,vec);
VECADD(state->co,par->co,vec);
break;
case PART_KINK_RADIAL:
VECSUB(vec,state->co,par->co);
Normalize(vec);
VecMulf(vec,amplitude*(float)sin(t));
normalize_v3(vec);
mul_v3_fl(vec,amplitude*(float)sin(t));
VECADD(state->co,state->co,vec);
break;
case PART_KINK_WAVE:
vec[axis]=1.0;
if(obmat)
Mat4Mul3Vecfl(obmat,vec);
mul_mat3_m4_v3(obmat,vec);
if(par_rot)
QuatMulVecf(par_rot,vec);
mul_qt_v3(par_rot,vec);
Projf(q1,vec,par->vel);
project_v3_v3v3(q1,vec,par->vel);
VECSUB(vec,vec,q1);
Normalize(vec);
normalize_v3(vec);
VecMulf(vec,amplitude*(float)sin(t));
mul_v3_fl(vec,amplitude*(float)sin(t));
VECADD(state->co,state->co,vec);
break;
@ -1885,46 +1885,46 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo
if(par_rot)
QUATCOPY(q2,par_rot)
else
vectoquat(par->vel,axis,(axis+1)%3,q2);
QuatMulVecf(q2,y_vec);
QuatMulVecf(q2,z_vec);
vec_to_quat(q2,par->vel,axis,(axis+1)%3);
mul_qt_v3(q2,y_vec);
mul_qt_v3(q2,z_vec);
VECSUB(vec_from_par,state->co,par->co);
VECCOPY(vec_one,vec_from_par);
radius=Normalize(vec_one);
radius=normalize_v3(vec_one);
inp_y=Inpf(y_vec,vec_one);
inp_z=Inpf(z_vec,vec_one);
inp_y=dot_v3v3(y_vec,vec_one);
inp_z=dot_v3v3(z_vec,vec_one);
if(inp_y>0.5){
VECCOPY(state_co,y_vec);
VecMulf(y_vec,amplitude*(float)cos(t));
VecMulf(z_vec,amplitude/2.0f*(float)sin(2.0f*t));
mul_v3_fl(y_vec,amplitude*(float)cos(t));
mul_v3_fl(z_vec,amplitude/2.0f*(float)sin(2.0f*t));
}
else if(inp_z>0.0){
VECCOPY(state_co,z_vec);
VecMulf(state_co,(float)sin(M_PI/3.0f));
mul_v3_fl(state_co,(float)sin(M_PI/3.0f));
VECADDFAC(state_co,state_co,y_vec,-0.5f);
VecMulf(y_vec,-amplitude*(float)cos(t + M_PI/3.0f));
VecMulf(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f));
mul_v3_fl(y_vec,-amplitude*(float)cos(t + M_PI/3.0f));
mul_v3_fl(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f));
}
else{
VECCOPY(state_co,z_vec);
VecMulf(state_co,-(float)sin(M_PI/3.0f));
mul_v3_fl(state_co,-(float)sin(M_PI/3.0f));
VECADDFAC(state_co,state_co,y_vec,-0.5f);
VecMulf(y_vec,amplitude*(float)-sin(t+M_PI/6.0f));
VecMulf(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f));
mul_v3_fl(y_vec,amplitude*(float)-sin(t+M_PI/6.0f));
mul_v3_fl(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f));
}
VecMulf(state_co,amplitude);
mul_v3_fl(state_co,amplitude);
VECADD(state_co,state_co,par->co);
VECSUB(vec_from_par,state->co,state_co);
length=Normalize(vec_from_par);
VecMulf(vec_from_par,MIN2(length,amplitude/2.0f));
length=normalize_v3(vec_from_par);
mul_v3_fl(vec_from_par,MIN2(length,amplitude/2.0f));
VECADD(state_co,par->co,y_vec);
VECADD(state_co,state_co,z_vec);
@ -1935,7 +1935,7 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo
if(t<shape){
shape=t/shape;
shape=(float)sqrt((double)shape);
VecLerpf(state->co,state->co,state_co,shape);
interp_v3_v3v3(state->co,state->co,state_co,shape);
}
else{
VECCOPY(state->co,state_co);
@ -1959,7 +1959,7 @@ static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clu
clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow);
else
clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow);
VecLerpf(state->co,state->co,par->co,clump);
interp_v3_v3v3(state->co,state->co,par->co,clump);
}
}
void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
@ -1991,7 +1991,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
VECSUB(efd.vec_to_point, state.co, eff->guide_loc);
VECCOPY(efd.nor, eff->guide_dir);
efd.distance = VecLength(efd.vec_to_point);
efd.distance = len_v3(efd.vec_to_point);
VECCOPY(data->vec_to_point, efd.vec_to_point);
data->strength = effector_falloff(eff, &efd, &point, weights);
@ -2038,33 +2038,33 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time)
return 0;
}
Mat4MulVecfl(eff->ob->obmat, guidevec);
Mat4Mul3Vecfl(eff->ob->obmat, guidedir);
mul_m4_v3(eff->ob->obmat, guidevec);
mul_mat3_m4_v3(eff->ob->obmat, guidedir);
Normalize(guidedir);
normalize_v3(guidedir);
VECCOPY(vec_to_point, data->vec_to_point);
if(guidetime != 0.0){
/* curve direction */
Crossf(temp, eff->guide_dir, guidedir);
angle = Inpf(eff->guide_dir, guidedir)/(VecLength(eff->guide_dir));
cross_v3_v3v3(temp, eff->guide_dir, guidedir);
angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir));
angle = saacos(angle);
VecRotToQuat(temp, angle, rot2);
QuatMulVecf(rot2, vec_to_point);
axis_angle_to_quat( rot2,temp, angle);
mul_qt_v3(rot2, vec_to_point);
/* curve tilt */
VecRotToQuat(guidedir, guidevec[3] - eff->guide_loc[3], rot2);
QuatMulVecf(rot2, vec_to_point);
axis_angle_to_quat( rot2,guidedir, guidevec[3] - eff->guide_loc[3]);
mul_qt_v3(rot2, vec_to_point);
}
/* curve taper */
if(cu->taperobj)
VecMulf(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100));
mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100));
else{ /* curve size*/
if(cu->flag & CU_PATH_RADIUS) {
VecMulf(vec_to_point, radius);
mul_v3_fl(vec_to_point, radius);
}
}
par.co[0] = par.co[1] = par.co[2] = 0.0f;
@ -2082,13 +2082,13 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time)
if(totstrength != 0.0){
if(totstrength > 1.0)
VecMulf(effect, 1.0f / totstrength);
mul_v3_fl(effect, 1.0f / totstrength);
CLAMP(totstrength, 0.0, 1.0);
//VECADD(effect,effect,pa_zero);
VecLerpf(state->co, state->co, effect, totstrength);
interp_v3_v3v3(state->co, state->co, effect, totstrength);
Normalize(veffect);
VecMulf(veffect, VecLength(state->vel));
normalize_v3(veffect);
mul_v3_fl(veffect, len_v3(state->vel));
VECCOPY(state->vel, veffect);
return 1;
}
@ -2103,7 +2103,7 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size
if((float)fabs((float)(-1.5+loc[0]+loc[1]+loc[2]))<1.5f*thres) return;
VECCOPY(rco,loc);
VecMulf(rco,t);
mul_v3_fl(rco,t);
rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2,0,2);
rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2,0,2);
rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2,0,2);
@ -2118,10 +2118,10 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float
float roughfac;
roughfac=fac*(float)pow((double)t,shape);
Vec2Copyf(rough,loc);
copy_v2_v2(rough,loc);
rough[0]=-1.0f+2.0f*rough[0];
rough[1]=-1.0f+2.0f*rough[1];
Vec2Mulf(rough,roughfac);
mul_v2_fl(rough,roughfac);
VECADDFAC(state->co,state->co,mat[0],rough[0]);
VECADDFAC(state->co,state->co,mat[1],rough[1]);
@ -2143,23 +2143,23 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK
pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint);
pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL);
VecMulf(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps);
mul_v3_fl(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps);
VecAddf(force, force, vec);
add_v3_v3v3(force, force, vec);
Normalize(force);
normalize_v3(force);
VECADDFAC(ca->co, (ca-1)->co, force, *length);
if(k < steps) {
VecSubf(vec, (ca+1)->co, ca->co);
*length = VecLength(vec);
sub_v3_v3v3(vec, (ca+1)->co, ca->co);
*length = len_v3(vec);
}
}
static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec)
{
if(*cur_length + length > max_length){
VecMulf(dvec, (max_length - *cur_length) / length);
mul_v3_fl(dvec, (max_length - *cur_length) / length);
VECADD(state->co, (state - 1)->co, dvec);
keys->steps = k;
/* something over the maximum step value */
@ -2173,13 +2173,13 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st
static void offset_child(ChildParticle *cpa, ParticleKey *par, ParticleKey *child, float flat, float radius)
{
VECCOPY(child->co,cpa->fuv);
VecMulf(child->co,radius);
mul_v3_fl(child->co,radius);
child->co[0]*=flat;
VECCOPY(child->vel,par->vel);
QuatMulVecf(par->rot,child->co);
mul_qt_v3(par->rot,child->co);
QUATCOPY(child->rot,par->rot);
@ -2248,14 +2248,14 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa
return;
if(ma->mode & MA_STR_SURFDIFF) {
Crossf(cross, surfnor, nor);
Crossf(nstrand, nor, cross);
cross_v3_v3v3(cross, surfnor, nor);
cross_v3_v3v3(nstrand, nor, cross);
blend= INPR(nstrand, surfnor);
CLAMP(blend, 0.0f, 1.0f);
VecLerpf(vnor, nstrand, surfnor, blend);
Normalize(vnor);
interp_v3_v3v3(vnor, nstrand, surfnor, blend);
normalize_v3(vnor);
}
else
VECCOPY(vnor, nor)
@ -2263,8 +2263,8 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa
if(ma->strand_surfnor > 0.0f) {
if(ma->strand_surfnor > surfdist) {
blend= (ma->strand_surfnor - surfdist)/ma->strand_surfnor;
VecLerpf(vnor, vnor, surfnor, blend);
Normalize(vnor);
interp_v3_v3v3(vnor, vnor, surfnor, blend);
normalize_v3(vnor);
}
}
@ -2441,7 +2441,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
if(part->path_start==0.0f) {
/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
VECCOPY(cpa_1st,co);
Mat4MulVecfl(ob->obmat,cpa_1st);
mul_m4_v3(ob->obmat,cpa_1st);
}
pa = psys->particles + cpa->parent;
@ -2539,8 +2539,8 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
do_path_effectors(&ctx->sim, cpa->pa[0], state, k, ctx->steps, keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec);
}
else {
VecSubf(eff_vec,(state+1)->co,state->co);
eff_length= VecLength(eff_vec);
sub_v3_v3v3(eff_vec,(state+1)->co,state->co);
eff_length= len_v3(eff_vec);
}
}
}
@ -2600,17 +2600,17 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
// }
// if(i<psys->totpart)
// VecLerpf(state->co, (pcache[i] + k)->co, state->co, branchfac);
// interp_v3_v3v3(state->co, (pcache[i] + k)->co, state->co, branchfac);
// else
// /* this is not threadsafe, but should only happen for
// * branching particles particles, which are not threaded */
// VecLerpf(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac);
// interp_v3_v3v3(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac);
//}
/* we have to correct velocity because of kink & clump */
if(k>1){
VECSUB((state-1)->vel,state->co,(state-2)->co);
VecMulf((state-1)->vel,0.5);
mul_v3_fl((state-1)->vel,0.5);
if(ctx->ma && (part->draw & PART_DRAW_MAT_COL))
get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel);
@ -2842,9 +2842,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/* dynamic hair is in object space */
/* keyed and baked are allready in global space */
if(hair_dm)
Mat4MulVecfl(sim->ob->obmat, result.co);
mul_m4_v3(sim->ob->obmat, result.co);
else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR))
Mat4MulVecfl(hairmat, result.co);
mul_m4_v3(hairmat, result.co);
VECCOPY(ca->co, result.co);
VECCOPY(ca->col, col);
@ -2852,8 +2852,8 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/*--modify paths and calculate rotation & velocity--*/
VecSubf(vec,(cache[p]+1)->co,cache[p]->co);
length = VecLength(vec);
sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co);
length = len_v3(vec);
effector= 1.0f;
if(vg_effector)
@ -2883,7 +2883,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/* calculate initial tangent for incremental rotations */
VECSUB(tangent, ca->co, (ca - 1)->co);
VECCOPY(prev_tangent, tangent);
Normalize(prev_tangent);
normalize_v3(prev_tangent);
/* First rotation is based on emitting face orientation. */
/* This is way better than having flipping rotations resulting */
@ -2891,13 +2891,13 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/* It's not an ideal solution though since it disregards the */
/* initial tangent, but taking that in to account will allow */
/* the possibility of flipping again. -jahka */
Mat3ToQuat_is_ok(rotmat, (ca-1)->rot);
mat3_to_quat_is_ok( (ca-1)->rot,rotmat);
}
else {
VECSUB(tangent, ca->co, (ca - 1)->co);
Normalize(tangent);
normalize_v3(tangent);
cosangle= Inpf(tangent, prev_tangent);
cosangle= dot_v3v3(tangent, prev_tangent);
/* note we do the comparison on cosangle instead of
* angle, since floating point accuracy makes it give
@ -2907,9 +2907,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
}
else {
angle= saacos(cosangle);
Crossf(normal, prev_tangent, tangent);
VecRotToQuat(normal, angle, q);
QuatMul((ca - 1)->rot, q, (ca - 2)->rot);
cross_v3_v3v3(normal, prev_tangent, tangent);
axis_angle_to_quat( q,normal, angle);
mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot);
}
VECCOPY(prev_tangent, tangent);
@ -3035,7 +3035,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* non-hair points are allready in global space */
if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
Mat4MulVecfl(hairmat, result.co);
mul_m4_v3(hairmat, result.co);
/* create rotations for proper creation of children */
if(k) {
@ -3045,7 +3045,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* calculate initial tangent for incremental rotations */
VECSUB(tangent, ca->co, (ca - 1)->co);
VECCOPY(prev_tangent, tangent);
Normalize(prev_tangent);
normalize_v3(prev_tangent);
/* First rotation is based on emitting face orientation. */
/* This is way better than having flipping rotations resulting */
@ -3053,13 +3053,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* It's not an ideal solution though since it disregards the */
/* initial tangent, but taking that in to account will allow */
/* the possibility of flipping again. -jahka */
Mat3ToQuat_is_ok(rotmat, (ca-1)->rot);
mat3_to_quat_is_ok( (ca-1)->rot,rotmat);
}
else {
VECSUB(tangent, ca->co, (ca - 1)->co);
Normalize(tangent);
normalize_v3(tangent);
cosangle= Inpf(tangent, prev_tangent);
cosangle= dot_v3v3(tangent, prev_tangent);
/* note we do the comparison on cosangle instead of
* angle, since floating point accuracy makes it give
@ -3069,9 +3069,9 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
else {
angle= saacos(cosangle);
Crossf(normal, prev_tangent, tangent);
VecRotToQuat(normal, angle, q);
QuatMul((ca - 1)->rot, q, (ca - 2)->rot);
cross_v3_v3v3(normal, prev_tangent, tangent);
axis_angle_to_quat( q,normal, angle);
mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot);
}
VECCOPY(prev_tangent, tangent);
@ -3095,13 +3095,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
else{
keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
VecLerpf(ca->col, sel_col, nosel_col, keytime);
interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime);
}
}
else{
if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){
keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
VecLerpf(ca->col, nosel_col, sel_col, keytime);
interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime);
}
else{
VECCOPY(ca->col, nosel_col);
@ -3145,12 +3145,12 @@ static void key_from_object(Object *ob, ParticleKey *key){
VECADD(key->vel,key->vel,key->co);
Mat4MulVecfl(ob->obmat,key->co);
Mat4MulVecfl(ob->obmat,key->vel);
Mat4ToQuat(ob->obmat,q);
mul_m4_v3(ob->obmat,key->co);
mul_m4_v3(ob->obmat,key->vel);
mat4_to_quat(q,ob->obmat);
VECSUB(key->vel,key->vel,key->co);
QuatMul(key->rot,q,key->rot);
mul_qt_qtqt(key->rot,q,key->rot);
}
#endif
@ -3162,7 +3162,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
mat[3][3]= 1.0f;
/* first axis is the normal */
CalcNormFloat(v1, v2, v3, mat[2]);
normal_tri_v3( mat[2],v1, v2, v3);
/* second axis along (1, 0) in uv space */
if(uv) {
@ -3181,18 +3181,18 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
mat[1][0]= w1*(v2[0] - v1[0]) + w2*(v3[0] - v1[0]);
mat[1][1]= w1*(v2[1] - v1[1]) + w2*(v3[1] - v1[1]);
mat[1][2]= w1*(v2[2] - v1[2]) + w2*(v3[2] - v1[2]);
Normalize(mat[1]);
normalize_v3(mat[1]);
}
else
mat[1][0]= mat[1][1]= mat[1][2]= 0.0f;
}
else {
VecSubf(mat[1], v2, v1);
Normalize(mat[1]);
sub_v3_v3v3(mat[1], v2, v1);
normalize_v3(mat[1]);
}
/* third as a cross product */
Crossf(mat[0], mat[1], mat[2]);
cross_v3_v3v3(mat[0], mat[1], mat[2]);
}
static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float mat[][4], int orco)
@ -3204,7 +3204,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
int i = pa->num_dmcache==DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache;
if (i==-1 || i >= dm->getNumTessFaces(dm)) { Mat4One(mat); return; }
if (i==-1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; }
mface=dm->getTessFaceData(dm,i,CD_MFACE);
osface=dm->getTessFaceData(dm,i,CD_ORIGSPACE);
@ -3253,8 +3253,8 @@ void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float *vec)
float mat[4][4];
psys_face_mat(0, dm, pa, mat, 0);
Mat4Transp(mat); /* cheap inverse for rotation matrix */
Mat4Mul3Vecfl(mat, vec);
transpose_m4(mat); /* cheap inverse for rotation matrix */
mul_mat3_m4_v3(mat, vec);
}
void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4])
@ -3263,7 +3263,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa
psys_mat_hair_to_object(ob, dm, from, pa, facemat);
Mat4MulMat4(hairmat, facemat, ob->obmat);
mul_m4_m4m4(hairmat, facemat, ob->obmat);
}
/************************************************/
@ -3850,8 +3850,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
if(!keyed && !cached) {
if((pa->flag & PARS_REKEY)==0) {
psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat);
Mat4MulVecfl(hairmat, state->co);
Mat4Mul3Vecfl(hairmat, state->vel);
mul_m4_v3(hairmat, state->co);
mul_mat3_m4_v3(hairmat, state->vel);
if(sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) {
do_guides(sim->psys->effectors, state, p, state->time);
@ -3864,7 +3864,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
}
}
else if(totchild){
//Mat4Invert(imat,ob->obmat);
//invert_m4_m4(imat,ob->obmat);
cpa=psys->child+p-totpart;
@ -3903,7 +3903,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
//VECCOPY(cpa_1st,co);
//Mat4MulVecfl(ob->obmat,cpa_1st);
//mul_m4_v3(ob->obmat,cpa_1st);
pa = psys->particles + cpa->parent;
@ -3980,22 +3980,22 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
/* try to estimate correct velocity */
if(vel){
ParticleKey tstate;
float length = VecLength(state->vel);
float length = len_v3(state->vel);
if(t>=0.001f){
tstate.time=t-0.001f;
psys_get_particle_on_path(sim,p,&tstate,0);
VECSUB(state->vel,state->co,tstate.co);
Normalize(state->vel);
normalize_v3(state->vel);
}
else{
tstate.time=t+0.001f;
psys_get_particle_on_path(sim,p,&tstate,0);
VECSUB(state->vel,tstate.co,state->co);
Normalize(state->vel);
normalize_v3(state->vel);
}
VecMulf(state->vel, length);
mul_v3_fl(state->vel, length);
}
}
}
@ -4102,16 +4102,16 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
keytime = (state->time - keys[1].time) / dfra;
/* convert velocity to timestep size */
VecMulf(keys[1].vel, dfra * timestep);
VecMulf(keys[2].vel, dfra * timestep);
mul_v3_fl(keys[1].vel, dfra * timestep);
mul_v3_fl(keys[2].vel, dfra * timestep);
psys_interpolate_particle(-1, keys, keytime, state, 1);
/* convert back to real velocity */
VecMulf(state->vel, 1.0f / (dfra * timestep));
mul_v3_fl(state->vel, 1.0f / (dfra * timestep));
VecLerpf(state->ave, keys[1].ave, keys[2].ave, keytime);
QuatInterpol(state->rot, keys[1].rot, keys[2].rot, keytime);
interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime);
interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime);
}
}
else {
@ -4185,8 +4185,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4];
float xvec[3] = {-1.0, 0.0, 0.0}, q[4];
VecSubf(vec, (cache+cache->steps-1)->co, cache->co);
len= Normalize(vec);
sub_v3_v3v3(vec, (cache+cache->steps-1)->co, cache->co);
len= normalize_v3(vec);
if(pa)
psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
@ -4199,17 +4199,17 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
if(!pa)
pa= psys->particles+cpa->pa[0];
vectoquat(xvec, ob->trackflag, ob->upflag, q);
QuatToMat4(q, obrotmat);
vec_to_quat( q,xvec, ob->trackflag, ob->upflag);
quat_to_mat4( obrotmat,q);
obrotmat[3][3]= 1.0f;
QuatToMat4(pa->state.rot, qmat);
Mat4MulMat4(mat, obrotmat, qmat);
quat_to_mat4( qmat,pa->state.rot);
mul_m4_m4m4(mat, obrotmat, qmat);
}
else {
/* make sure that we get a proper side vector */
if(fabs(Inpf(nor,vec))>0.999999) {
if(fabs(Inpf(nor,xvec))>0.999999) {
if(fabs(dot_v3v3(nor,vec))>0.999999) {
if(fabs(dot_v3v3(nor,xvec))>0.999999) {
nor[0] = 0.0f;
nor[1] = 1.0f;
nor[2] = 0.0f;
@ -4220,11 +4220,11 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
nor[2] = 0.0f;
}
}
Crossf(side, nor, vec);
Normalize(side);
Crossf(nor, vec, side);
cross_v3_v3v3(side, nor, vec);
normalize_v3(side);
cross_v3_v3v3(nor, vec, side);
Mat4One(mat);
unit_m4(mat);
VECCOPY(mat[0], vec);
VECCOPY(mat[1], side);
VECCOPY(mat[2], nor);
@ -4245,62 +4245,62 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
if(bb->lock && (bb->align == PART_BB_VIEW)) {
VECCOPY(xvec, bb->ob->obmat[0]);
Normalize(xvec);
normalize_v3(xvec);
VECCOPY(yvec, bb->ob->obmat[1]);
Normalize(yvec);
normalize_v3(yvec);
VECCOPY(zvec, bb->ob->obmat[2]);
Normalize(zvec);
normalize_v3(zvec);
}
else if(bb->align == PART_BB_VEL) {
float temp[3];
VECCOPY(temp, bb->vel);
Normalize(temp);
normalize_v3(temp);
VECSUB(zvec, bb->ob->obmat[3], bb->vec);
if(bb->lock) {
float fac = -Inpf(zvec, temp);
float fac = -dot_v3v3(zvec, temp);
VECADDFAC(zvec, zvec, temp, fac);
}
Normalize(zvec);
normalize_v3(zvec);
Crossf(xvec,temp,zvec);
Normalize(xvec);
cross_v3_v3v3(xvec,temp,zvec);
normalize_v3(xvec);
Crossf(yvec,zvec,xvec);
cross_v3_v3v3(yvec,zvec,xvec);
}
else {
VECSUB(zvec, bb->ob->obmat[3], bb->vec);
if(bb->lock)
zvec[bb->align] = 0.0f;
Normalize(zvec);
normalize_v3(zvec);
if(bb->align < PART_BB_VIEW)
Crossf(xvec, onevec, zvec);
cross_v3_v3v3(xvec, onevec, zvec);
else
Crossf(xvec, bb->ob->obmat[1], zvec);
Normalize(xvec);
cross_v3_v3v3(xvec, bb->ob->obmat[1], zvec);
normalize_v3(xvec);
Crossf(yvec,zvec,xvec);
cross_v3_v3v3(yvec,zvec,xvec);
}
VECCOPY(tvec, xvec);
VECCOPY(tvec2, yvec);
VecMulf(xvec, cos(bb->tilt * (float)M_PI));
VecMulf(tvec2, sin(bb->tilt * (float)M_PI));
mul_v3_fl(xvec, cos(bb->tilt * (float)M_PI));
mul_v3_fl(tvec2, sin(bb->tilt * (float)M_PI));
VECADD(xvec, xvec, tvec2);
VecMulf(yvec, cos(bb->tilt * (float)M_PI));
VecMulf(tvec, -sin(bb->tilt * (float)M_PI));
mul_v3_fl(yvec, cos(bb->tilt * (float)M_PI));
mul_v3_fl(tvec, -sin(bb->tilt * (float)M_PI));
VECADD(yvec, yvec, tvec);
VecMulf(xvec, bb->size);
VecMulf(yvec, bb->size);
mul_v3_fl(xvec, bb->size);
mul_v3_fl(yvec, bb->size);
VECADDFAC(center, bb->vec, xvec, bb->offset[0]);
VECADDFAC(center, center, yvec, bb->offset[1]);

@ -54,7 +54,7 @@
#include "BLI_rand.h"
#include "BLI_jitter.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
@ -405,7 +405,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
min[2]-=d/2.0f;
for(i=0,mv=mvert; i<totvert; i++,mv++){
VecSubf(vec,mv->co,min);
sub_v3_v3v3(vec,mv->co,min);
vec[0]/=delta[0];
vec[1]/=delta[1];
vec[2]/=delta[2];
@ -447,7 +447,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
VECCOPY(v2,mvert[mface->v2].co);
VECCOPY(v3,mvert[mface->v3].co);
if(AxialLineIntersectsTriangle(a,co1, co2, v2, v3, v1, &lambda)){
if(isect_axial_line_tri_v3(a,co1, co2, v2, v3, v1, &lambda)){
if(from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else /* store number of intersections */
@ -457,7 +457,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
if(mface->v4){
VECCOPY(v4,mvert[mface->v4].co);
if(AxialLineIntersectsTriangle(a,co1, co2, v4, v1, v3, &lambda)){
if(isect_axial_line_tri_v3(a,co1, co2, v4, v1, v3, &lambda)){
if(from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else
@ -577,10 +577,10 @@ static void psys_uv_to_w(float u, float v, int quad, float *w)
if(quad) {
vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f;
MeanValueWeights(vert, 4, co, w);
interp_weights_poly_v3( w,vert, 4, co);
}
else {
MeanValueWeights(vert, 3, co, w);
interp_weights_poly_v3( w,vert, 3, co);
w[3]= 0.0f;
}
}
@ -669,8 +669,8 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData
psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0);
Normalize(nor);
VecMulf(nor,-100.0);
normalize_v3(nor);
mul_v3_fl(nor,-100.0);
VECADD(co2,co1,nor);
@ -684,7 +684,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData
v2=mvert[mface->v2].co;
v3=mvert[mface->v3].co;
if(LineIntersectsTriangle(co1, co2, v2, v3, v1, &cur_d, 0)){
if(isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)){
if(cur_d<min_d){
min_d=cur_d;
pa->foffset=cur_d*50.0f; /* to the middle of volume */
@ -694,7 +694,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData
if(mface->v4){
v4=mvert[mface->v4].co;
if(LineIntersectsTriangle(co1, co2, v4, v1, v3, &cur_d, 0)){
if(isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)){
if(cur_d<min_d){
min_d=cur_d;
pa->foffset=cur_d*50.0f; /* to the middle of volume */
@ -776,18 +776,18 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData
// int min_seam=0, near_vert=0;
// /* find closest seam */
// for(i=0; i<ctx->totseam; i++, seam++){
// VecSubf(temp,co1,seam->v0);
// inp=Inpf(temp,seam->dir)/seam->length2;
// sub_v3_v3v3(temp,co1,seam->v0);
// inp=dot_v3v3(temp,seam->dir)/seam->length2;
// if(inp<0.0f){
// cur_len=VecLenf(co1,seam->v0);
// cur_len=len_v3v3(co1,seam->v0);
// }
// else if(inp>1.0f){
// cur_len=VecLenf(co1,seam->v1);
// cur_len=len_v3v3(co1,seam->v1);
// }
// else{
// VecCopyf(temp2,seam->dir);
// VecMulf(temp2,inp);
// cur_len=VecLenf(temp,temp2);
// copy_v3_v3(temp2,seam->dir);
// mul_v3_fl(temp2,inp);
// cur_len=len_v3v3(temp,temp2);
// }
// if(cur_len<min_len){
// min_len=cur_len;
@ -799,27 +799,27 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData
// }
// seam=ctx->seams+min_seam;
//
// VecCopyf(temp,seam->v0);
// copy_v3_v3(temp,seam->v0);
//
// if(near_vert){
// if(near_vert==-1)
// VecSubf(tan,co1,seam->v0);
// sub_v3_v3v3(tan,co1,seam->v0);
// else{
// VecSubf(tan,co1,seam->v1);
// VecCopyf(temp,seam->v1);
// sub_v3_v3v3(tan,co1,seam->v1);
// copy_v3_v3(temp,seam->v1);
// }
// Normalize(tan);
// normalize_v3(tan);
// }
// else{
// VecCopyf(tan,seam->tan);
// VecSubf(temp2,co1,temp);
// if(Inpf(tan,temp2)<0.0f)
// VecNegf(tan);
// copy_v3_v3(tan,seam->tan);
// sub_v3_v3v3(temp2,co1,temp);
// if(dot_v3v3(tan,temp2)<0.0f)
// negate_v3(tan);
// }
// for(w=0; w<maxw; w++){
// VecSubf(temp2,ptn[w].co,temp);
// if(Inpf(tan,temp2)<0.0f){
// sub_v3_v3v3(temp2,ptn[w].co,temp);
// if(dot_v3v3(tan,temp2)<0.0f){
// parent[w]=-1;
// pweight[w]=0.0f;
// }
@ -989,12 +989,12 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene,
// for(p=0, ed=medge; p<totedge; p++,ed++){
// if(ed->flag&ME_SEAM){
// VecCopyf(cur_seam->v0,(mvert+ed->v1)->co);
// VecCopyf(cur_seam->v1,(mvert+ed->v2)->co);
// copy_v3_v3(cur_seam->v0,(mvert+ed->v1)->co);
// copy_v3_v3(cur_seam->v1,(mvert+ed->v2)->co);
// VecSubf(cur_seam->dir,cur_seam->v1,cur_seam->v0);
// sub_v3_v3v3(cur_seam->dir,cur_seam->v1,cur_seam->v0);
// cur_seam->length2=VecLength(cur_seam->dir);
// cur_seam->length2=len_v3(cur_seam->dir);
// cur_seam->length2*=cur_seam->length2;
// temp[0]=(float)((mvert+ed->v1)->no[0]);
@ -1004,12 +1004,12 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene,
// temp2[1]=(float)((mvert+ed->v2)->no[1]);
// temp2[2]=(float)((mvert+ed->v2)->no[2]);
// VecAddf(cur_seam->nor,temp,temp2);
// Normalize(cur_seam->nor);
// add_v3_v3v3(cur_seam->nor,temp,temp2);
// normalize_v3(cur_seam->nor);
// Crossf(cur_seam->tan,cur_seam->dir,cur_seam->nor);
// cross_v3_v3v3(cur_seam->tan,cur_seam->dir,cur_seam->nor);
// Normalize(cur_seam->tan);
// normalize_v3(cur_seam->tan);
// cur_seam++;
// }
@ -1035,7 +1035,7 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene,
cpa->fuv[0]=2.0f*BLI_frand()-1.0f;
cpa->fuv[1]=2.0f*BLI_frand()-1.0f;
cpa->fuv[2]=2.0f*BLI_frand()-1.0f;
length=VecLength(cpa->fuv);
length=len_v3(cpa->fuv);
}
cpa->num=-1;
@ -1176,10 +1176,10 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene,
v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT);
VECCOPY(co4, v4->co);
}
cur= AreaQ3Dfl(co1, co2, co3, co4);
cur= area_quad_v3(co1, co2, co3, co4);
}
else
cur= AreaT3Dfl(co1, co2, co3);
cur= area_tri_v3(co1, co2, co3);
if(cur>maxweight)
maxweight=cur;
@ -1682,7 +1682,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f);
r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f);
r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f);
NormalQuat(r_rot);
normalize_qt(r_rot);
r_phase = PSYS_FRAND(p + 20);
@ -1699,15 +1699,15 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
psys_get_particle_state(&tsim, pa->num, &state, 1);
psys_get_from_key(&state, loc, nor, rot, 0);
QuatMulVecf(rot, vtan);
QuatMulVecf(rot, utan);
mul_qt_v3(rot, vtan);
mul_qt_v3(rot, utan);
VECCOPY(p_vel, state.vel);
speed=Normalize(p_vel);
VecMulf(p_vel, Inpf(r_vel, p_vel));
speed=normalize_v3(p_vel);
mul_v3_fl(p_vel, dot_v3v3(r_vel, p_vel));
VECSUB(p_vel, r_vel, p_vel);
Normalize(p_vel);
VecMulf(p_vel, speed);
normalize_v3(p_vel);
mul_v3_fl(p_vel, speed);
VECCOPY(pa->fuv, loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */
}
@ -1731,46 +1731,46 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* particles live in global space so */
/* let's convert: */
/* -location */
Mat4MulVecfl(ob->obmat,loc);
mul_m4_v3(ob->obmat,loc);
/* -normal */
Mat4Mul3Vecfl(ob->obmat,nor);
Normalize(nor);
mul_mat3_m4_v3(ob->obmat,nor);
normalize_v3(nor);
/* -tangent */
if(part->tanfac!=0.0){
//float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
float phase=0.0f;
VecMulf(vtan,-(float)cos(M_PI*(part->tanphase+phase)));
mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase)));
fac=-(float)sin(M_PI*(part->tanphase+phase));
VECADDFAC(vtan,vtan,utan,fac);
Mat4Mul3Vecfl(ob->obmat,vtan);
mul_mat3_m4_v3(ob->obmat,vtan);
VECCOPY(utan,nor);
VecMulf(utan,Inpf(vtan,nor));
mul_v3_fl(utan,dot_v3v3(vtan,nor));
VECSUB(vtan,vtan,utan);
Normalize(vtan);
normalize_v3(vtan);
}
/* -velocity */
if(part->randfac!=0.0){
Mat4Mul3Vecfl(ob->obmat,r_vel);
Normalize(r_vel);
mul_mat3_m4_v3(ob->obmat,r_vel);
normalize_v3(r_vel);
}
/* -angular velocity */
if(part->avemode==PART_AVE_RAND){
Mat4Mul3Vecfl(ob->obmat,r_ave);
Normalize(r_ave);
mul_mat3_m4_v3(ob->obmat,r_ave);
normalize_v3(r_ave);
}
/* -rotation */
if(part->randrotfac != 0.0f){
Mat4ToQuat(ob->obmat,rot);
QuatMul(r_rot,r_rot,rot);
mat4_to_quat(rot,ob->obmat);
mul_qt_qtqt(r_rot,r_rot,rot);
}
}
@ -1785,8 +1785,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* boids store direction in ave */
if(fabs(nor[2])==1.0f) {
VecSubf(pa->state.ave, loc, ob->obmat[3]);
Normalize(pa->state.ave);
sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]);
normalize_v3(pa->state.ave);
}
else {
VECCOPY(pa->state.ave, nor);
@ -1799,17 +1799,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
/* calculate rotation matrix */
Projf(dvec, r_vel, pa->state.ave);
VecSubf(mat[0], pa->state.ave, dvec);
Normalize(mat[0]);
project_v3_v3v3(dvec, r_vel, pa->state.ave);
sub_v3_v3v3(mat[0], pa->state.ave, dvec);
normalize_v3(mat[0]);
VECCOPY(mat[2], r_vel);
VecMulf(mat[2], -1.0f);
Normalize(mat[2]);
Crossf(mat[1], mat[2], mat[0]);
mul_v3_fl(mat[2], -1.0f);
normalize_v3(mat[2]);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
/* apply rotation */
Mat3ToQuat_is_ok(mat, q);
QuatCopy(pa->state.rot, q);
mat3_to_quat_is_ok( q,mat);
copy_qt_qt(pa->state.rot, q);
bpa->data.health = part->boids->health;
bpa->data.mode = eBoidMode_InAir;
@ -1828,7 +1828,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* *emitter velocity */
if(dtime!=0.0 && part->obfac!=0.0){
VECSUB(vel,loc,pa->state.co);
VecMulf(vel,part->obfac/dtime);
mul_v3_fl(vel,part->obfac/dtime);
}
/* *emitter normal */
@ -1843,17 +1843,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* *emitter object orientation */
if(part->ob_vel[0]!=0.0) {
VECCOPY(vec, ob->obmat[0]);
Normalize(vec);
normalize_v3(vec);
VECADDFAC(vel, vel, vec, part->ob_vel[0]);
}
if(part->ob_vel[1]!=0.0) {
VECCOPY(vec, ob->obmat[1]);
Normalize(vec);
normalize_v3(vec);
VECADDFAC(vel, vel, vec, part->ob_vel[1]);
}
if(part->ob_vel[2]!=0.0) {
VECCOPY(vec, ob->obmat[2]);
Normalize(vec);
normalize_v3(vec);
VECADDFAC(vel, vel, vec, part->ob_vel[2]);
}
@ -1874,7 +1874,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
// ptex.ivel*=icu->curval;
//}
VecMulf(vel,ptex.ivel);
mul_v3_fl(vel,ptex.ivel);
VECCOPY(pa->state.vel,vel);
@ -1889,10 +1889,10 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* create vector into which rotation is aligned */
switch(part->rotmode){
case PART_ROT_NOR:
VecCopyf(rot_vec, nor);
copy_v3_v3(rot_vec, nor);
break;
case PART_ROT_VEL:
VecCopyf(rot_vec, vel);
copy_v3_v3(rot_vec, vel);
break;
case PART_ROT_GLOB_X:
case PART_ROT_GLOB_Y:
@ -1902,28 +1902,28 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
case PART_ROT_OB_X:
case PART_ROT_OB_Y:
case PART_ROT_OB_Z:
VecCopyf(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
break;
}
/* create rotation quat */
VecNegf(rot_vec);
vectoquat(rot_vec, OB_POSX, OB_POSZ, q2);
negate_v3(rot_vec);
vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ);
/* randomize rotation quat */
if(part->randrotfac!=0.0f)
QuatInterpol(rot, q2, r_rot, part->randrotfac);
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
else
QuatCopy(rot,q2);
copy_qt_qt(rot,q2);
/* rotation phase */
phasefac = part->phasefac;
if(part->randphasefac != 0.0f)
phasefac += part->randphasefac * r_phase;
VecRotToQuat(x_vec, phasefac*(float)M_PI, q_phase);
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
/* combine base rotation & phase */
QuatMul(pa->state.rot, rot, q_phase);
mul_qt_qtqt(pa->state.rot, rot, q_phase);
}
/* -angular velocity */
@ -1939,13 +1939,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
VECCOPY(pa->state.ave,r_ave);
break;
}
Normalize(pa->state.ave);
VecMulf(pa->state.ave,part->avefac);
normalize_v3(pa->state.ave);
mul_v3_fl(pa->state.ave,part->avefac);
//icu=find_ipocurve(psys->part->ipo,PART_EMIT_AVE);
//if(icu){
// calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta)));
// VecMulf(pa->state.ave,icu->curval);
// mul_v3_fl(pa->state.ave,icu->curval);
//}
}
}
@ -2157,7 +2157,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
// }
// }
// else{
// dist=VecLenf(pa->state.co, re->state.co);
// dist=len_v3v3(pa->state.co, re->state.co);
// if(dist <= re->size){
// if(pa->alive==PARS_UNBORN){
// pa->time=re->time;
@ -2168,12 +2168,12 @@ static void set_keyed_keys(ParticleSimulationData *sim)
// float vec[3];
// VECSUB(vec,pa->state.co, re->state.co);
// if(birth==0)
// VecMulf(vec,(float)pow(1.0f-dist/re->size,part->reactshape));
// mul_v3_fl(vec,(float)pow(1.0f-dist/re->size,part->reactshape));
// VECADDFAC(pa->state.vel,pa->state.vel,vec,part->reactfac);
// VECADDFAC(pa->state.vel,pa->state.vel,re->state.vel,part->partfac);
// }
// if(birth)
// VecMulf(pa->state.vel,(float)pow(1.0f-dist/re->size,part->reactshape));
// mul_v3_fl(pa->state.vel,(float)pow(1.0f-dist/re->size,part->reactshape));
// }
// }
// }
@ -2301,7 +2301,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
/* calculate air-particle interaction */
if(part->dragfac!=0.0f){
fac=-part->dragfac*pa->size*pa->size*VecLength(states[i].vel);
fac=-part->dragfac*pa->size*pa->size*len_v3(states[i].vel);
VECADDFAC(force,force,states[i].vel,fac);
}
@ -2313,7 +2313,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
}
/* force to acceleration*/
VecMulf(force,1.0f/pa_mass);
mul_v3_fl(force,1.0f/pa_mass);
/* add global acceleration (gravitation) */
if(sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY
@ -2321,7 +2321,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
&& (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) {
float gravity[3];
VECCOPY(gravity, sim->scene->physics_settings.gravity);
VecMulf(gravity, part->effector_weights->global_gravity);
mul_v3_fl(gravity, part->effector_weights->global_gravity);
VECADD(force,force,gravity);
}
@ -2348,9 +2348,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
switch(i){
case 0:
VECCOPY(dx[0],states->vel);
VecMulf(dx[0],dtime);
mul_v3_fl(dx[0],dtime);
VECCOPY(dv[0],force);
VecMulf(dv[0],dtime);
mul_v3_fl(dv[0],dtime);
VECADDFAC(states[1].co,states->co,dx[0],0.5f);
VECADDFAC(states[1].vel,states->vel,dv[0],0.5f);
@ -2358,18 +2358,18 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
break;
case 1:
VECADDFAC(dx[1],states->vel,dv[0],0.5f);
VecMulf(dx[1],dtime);
mul_v3_fl(dx[1],dtime);
VECCOPY(dv[1],force);
VecMulf(dv[1],dtime);
mul_v3_fl(dv[1],dtime);
VECADDFAC(states[2].co,states->co,dx[1],0.5f);
VECADDFAC(states[2].vel,states->vel,dv[1],0.5f);
break;
case 2:
VECADDFAC(dx[2],states->vel,dv[1],0.5f);
VecMulf(dx[2],dtime);
mul_v3_fl(dx[2],dtime);
VECCOPY(dv[2],force);
VecMulf(dv[2],dtime);
mul_v3_fl(dv[2],dtime);
VECADD(states[3].co,states->co,dx[2]);
VECADD(states[3].vel,states->vel,dv[2]);
@ -2377,9 +2377,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
break;
case 3:
VECADD(dx[3],states->vel,dv[2]);
VecMulf(dx[3],dtime);
mul_v3_fl(dx[3],dtime);
VECCOPY(dv[3],force);
VecMulf(dv[3],dtime);
mul_v3_fl(dv[3],dtime);
VECADDFAC(pa->state.co,states->co,dx[0],1.0f/6.0f);
VECADDFAC(pa->state.co,pa->state.co,dx[1],1.0f/3.0f);
@ -2397,7 +2397,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
/* damp affects final velocity */
if(part->dampfac!=0.0)
VecMulf(pa->state.vel,1.0f-part->dampfac);
mul_v3_fl(pa->state.vel,1.0f-part->dampfac);
VECCOPY(pa->state.ave, states->ave);
@ -2414,7 +2414,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
VECCOPY(pa->state.co,tkey.co);
/* guides don't produce valid velocity */
VECSUB(pa->state.vel,tkey.co,pa->prev_state.co);
VecMulf(pa->state.vel,1.0f/dtime);
mul_v3_fl(pa->state.vel,1.0f/dtime);
pa->state.time=tkey.time;
}
}
@ -2426,35 +2426,35 @@ static void rotate_particle(ParticleSettings *part, ParticleData *pa, float dfra
if((part->flag & PART_ROT_DYN)==0){
if(part->avemode==PART_AVE_SPIN){
float angle;
float len1 = VecLength(pa->prev_state.vel);
float len2 = VecLength(pa->state.vel);
float len1 = len_v3(pa->prev_state.vel);
float len2 = len_v3(pa->state.vel);
if(len1==0.0f || len2==0.0f)
pa->state.ave[0]=pa->state.ave[1]=pa->state.ave[2]=0.0f;
else{
Crossf(pa->state.ave,pa->prev_state.vel,pa->state.vel);
Normalize(pa->state.ave);
angle=Inpf(pa->prev_state.vel,pa->state.vel)/(len1*len2);
VecMulf(pa->state.ave,saacos(angle)/dtime);
cross_v3_v3v3(pa->state.ave,pa->prev_state.vel,pa->state.vel);
normalize_v3(pa->state.ave);
angle=dot_v3v3(pa->prev_state.vel,pa->state.vel)/(len1*len2);
mul_v3_fl(pa->state.ave,saacos(angle)/dtime);
}
VecRotToQuat(pa->state.vel,dtime*part->avefac,rot2);
axis_angle_to_quat(rot2,pa->state.vel,dtime*part->avefac);
}
}
rotfac=VecLength(pa->state.ave);
if(rotfac==0.0){ /* QuatOne (in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */
rotfac=len_v3(pa->state.ave);
if(rotfac==0.0){ /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */
rot1[0]=1.0;
rot1[1]=rot1[2]=rot1[3]=0;
}
else{
VecRotToQuat(pa->state.ave,rotfac*dtime,rot1);
axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime);
}
QuatMul(pa->state.rot,rot1,pa->prev_state.rot);
QuatMul(pa->state.rot,rot2,pa->state.rot);
mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot);
mul_qt_qtqt(pa->state.rot,rot2,pa->state.rot);
/* keep rotation quat in good health */
NormalQuat(pa->state.rot);
normalize_qt(pa->state.rot);
}
/* convert from triangle barycentric weights to quad mean value weights */
@ -2471,7 +2471,7 @@ static void intersect_dm_quad_weights(float *v1, float *v2, float *v3, float *v4
co[1]= v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3];
co[2]= v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3];
MeanValueWeights(vert, 4, co, w);
interp_weights_poly_v3( w,vert, 4, co);
}
/* check intersection with a derivedmesh */
@ -2537,18 +2537,18 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos
DO_MINMAX(v3,min,max);
if(mface->v4)
DO_MINMAX(v4,min,max)
if(AabbIntersectAabb(min,max,p_min,p_max)==0)
if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0)
continue;
}
else{
VECCOPY(min, face_minmax+6*i);
VECCOPY(max, face_minmax+6*i+3);
if(AabbIntersectAabb(min,max,p_min,p_max)==0)
if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0)
continue;
}
if(radius>0.0f){
if(SweepingSphereIntersectsTriangleUV(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){
if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){
if(cur_d<*min_d){
*min_d=cur_d;
VECCOPY(ipoint,cur_ipoint);
@ -2557,7 +2557,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos
}
}
if(mface->v4){
if(SweepingSphereIntersectsTriangleUV(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){
if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){
if(cur_d<*min_d){
*min_d=cur_d;
VECCOPY(ipoint,cur_ipoint);
@ -2568,7 +2568,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos
}
}
else{
if(LineIntersectsTriangle(co1, co2, v1, v2, v3, &cur_d, cur_uv)){
if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){
if(cur_d<*min_d){
*min_d=cur_d;
min_w[0]= 1.0 - cur_uv[0] - cur_uv[1];
@ -2582,7 +2582,7 @@ int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos
}
}
if(mface->v4){
if(LineIntersectsTriangle(co1, co2, v1, v3, v4, &cur_d, cur_uv)){
if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){
if(cur_d<*min_d){
*min_d=cur_d;
min_w[0]= 1.0 - cur_uv[0] - cur_uv[1];
@ -2618,7 +2618,7 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B
VECCOPY(vel, v[ face->v1 ].co);
VECADD(vel, vel, v[ face->v2 ].co);
VECADD(vel, vel, v[ face->v3 ].co);
VecMulf(vel, 0.33334f);
mul_v3_fl(vel, 0.33334f);
/* substract face velocity, in other words convert to
a coordinate system where only the particle moves */
@ -2628,16 +2628,16 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B
do
{
if(ray->radius == 0.0f) {
if(LineIntersectsTriangle(co1, co2, t0, t1, t2, &t, uv)) {
if(isect_line_tri_v3(co1, co2, t0, t1, t2, &t, uv)) {
if(t >= 0.0f && t < hit->dist/col->ray_len) {
hit->dist = col->ray_len * t;
hit->index = index;
/* calculate normal that's facing the particle */
CalcNormFloat(t0, t1, t2, col->nor);
normal_tri_v3( col->nor,t0, t1, t2);
VECSUB(temp, co2, co1);
if(Inpf(col->nor, temp) > 0.0f)
VecNegf(col->nor);
if(dot_v3v3(col->nor, temp) > 0.0f)
negate_v3(col->nor);
VECCOPY(col->vel,vel);
@ -2647,15 +2647,15 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B
}
}
else {
if(SweepingSphereIntersectsTriangleUV(co1, co2, ray->radius, t0, t1, t2, &t, ipoint)) {
if(isect_sweeping_sphere_tri_v3(co1, co2, ray->radius, t0, t1, t2, &t, ipoint)) {
if(t >=0.0f && t < hit->dist/col->ray_len) {
hit->dist = col->ray_len * t;
hit->index = index;
VecLerpf(temp, co1, co2, t);
interp_v3_v3v3(temp, co1, co2, t);
VECSUB(col->nor, temp, ipoint);
Normalize(col->nor);
normalize_v3(col->nor);
VECCOPY(col->vel,vel);
@ -2706,7 +2706,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
VECSUB(ray_dir, col.co2, col.co1);
hit.index = -1;
hit.dist = col.ray_len = VecLength(ray_dir);
hit.dist = col.ray_len = len_v3(ray_dir);
/* even if particle is stationary we want to check for moving colliders */
/* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */
@ -2738,10 +2738,10 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
float t = hit.dist/col.ray_len; /* time of collision between this iteration */
float dt = col.t + t * (1.0f - col.t); /* time of collision between frame change*/
VecLerpf(co, col.co1, col.co2, t);
interp_v3_v3v3(co, col.co1, col.co2, t);
VECSUB(vec, col.co2, col.co1);
VecMulf(col.vel, 1.0f-col.t);
mul_v3_fl(col.vel, 1.0f-col.t);
/* particle dies in collision */
if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) {
@ -2752,9 +2752,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f));
VECCOPY(pa->state.co, co);
VecLerpf(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt);
QuatInterpol(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt);
VecLerpf(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt);
interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt);
interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt);
interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt);
/* particle is dead so we don't need to calculate further */
deflections=max_deflections;
@ -2772,13 +2772,13 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
CLAMP(frict,0.0,1.0);
/* treat normal & tangent components separately */
inp = Inpf(col.nor, vec);
inp_v = Inpf(col.nor, col.vel);
inp = dot_v3v3(col.nor, vec);
inp_v = dot_v3v3(col.nor, col.vel);
VECADDFAC(tan_vec, vec, col.nor, -inp);
VECADDFAC(tan_vel, col.vel, col.nor, -inp_v);
if((part->flag & PART_ROT_DYN)==0)
VecLerpf(tan_vec, tan_vec, tan_vel, frict);
interp_v3_v3v3(tan_vec, tan_vec, tan_vel, frict);
VECCOPY(nor_vec, col.nor);
inp *= 1.0f - damp;
@ -2788,9 +2788,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
/* special case for object hitting the particle from behind */
if(through==0 && ((inp_v>0 && inp>0 && inp_v>inp) || (inp_v<0 && inp<0 && inp_v<inp)))
VecMulf(nor_vec, inp_v);
mul_v3_fl(nor_vec, inp_v);
else
VecMulf(nor_vec, inp_v + (through ? 1.0f : -1.0f) * inp);
mul_v3_fl(nor_vec, inp_v + (through ? 1.0f : -1.0f) * inp);
/* angular <-> linear velocity - slightly more physical and looks even nicer than before */
if(part->flag & PART_ROT_DYN) {
@ -2800,37 +2800,37 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
VECSUB(surface_vel, tan_vec, tan_vel);
/* direction of rolling friction */
Crossf(rot_vel, pa->state.ave, col.nor);
cross_v3_v3v3(rot_vel, pa->state.ave, col.nor);
/* convert to current dt */
VecMulf(rot_vel, (timestep*dfra) * (1.0f - col.t));
VecMulf(rot_vel, pa->size);
mul_v3_fl(rot_vel, (timestep*dfra) * (1.0f - col.t));
mul_v3_fl(rot_vel, pa->size);
/* apply sliding friction */
VECSUB(surface_vel, surface_vel, rot_vel);
VECCOPY(friction, surface_vel);
VecMulf(surface_vel, 1.0 - frict);
VecMulf(friction, frict);
mul_v3_fl(surface_vel, 1.0 - frict);
mul_v3_fl(friction, frict);
/* sliding changes angular velocity */
Crossf(dave, col.nor, friction);
VecMulf(dave, 1.0f/MAX2(pa->size, 0.001));
cross_v3_v3v3(dave, col.nor, friction);
mul_v3_fl(dave, 1.0f/MAX2(pa->size, 0.001));
/* we assume rolling friction is around 0.01 of sliding friction */
VecMulf(rot_vel, 1.0 - frict*0.01);
mul_v3_fl(rot_vel, 1.0 - frict*0.01);
/* change in angular velocity has to be added to the linear velocity too */
Crossf(dvel, dave, col.nor);
VecMulf(dvel, pa->size);
cross_v3_v3v3(dvel, dave, col.nor);
mul_v3_fl(dvel, pa->size);
VECADD(rot_vel, rot_vel, dvel);
VECADD(surface_vel, surface_vel, rot_vel);
VECADD(tan_vec, surface_vel, tan_vel);
/* convert back to normal time */
VecMulf(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001));
mul_v3_fl(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001));
VecMulf(pa->state.ave, 1.0 - frict*0.01);
mul_v3_fl(pa->state.ave, 1.0 - frict*0.01);
VECADD(pa->state.ave, pa->state.ave, dave);
}
@ -2839,7 +2839,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
/* calculate velocity from collision vector */
VECCOPY(vel, vec);
VecMulf(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001));
mul_v3_fl(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001));
/* make sure we don't hit the current face again */
VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f));
@ -2854,15 +2854,15 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
/* store state for reactors */
//VECCOPY(reaction_state.co, co);
//VecLerpf(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt);
//QuatInterpol(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt);
//interp_v3_v3v3(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt);
//interp_qt_qtqt(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt);
/* set coordinates for next iteration */
VECCOPY(col.co1, co);
VECADDFAC(col.co2, co, vec, 1.0f - t);
col.t = dt;
if(VecLength(vec) < 0.001 && VecLength(pa->state.vel) < 0.001) {
if(len_v3(vec) < 0.001 && len_v3(pa->state.vel) < 0.001) {
/* kill speed to stop slipping */
VECCOPY(pa->state.vel,zerovec);
VECCOPY(pa->state.co, co);
@ -3011,7 +3011,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
VECSUB(temp, key->co, (key+1)->co);
VECCOPY(mvert->co, key->co);
VECADD(mvert->co, mvert->co, temp);
Mat4MulVecfl(hairmat, mvert->co);
mul_m4_v3(hairmat, mvert->co);
mvert++;
medge->v1 = pa->hair_index - 1;
@ -3030,7 +3030,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
}
VECCOPY(mvert->co, key->co);
Mat4MulVecfl(hairmat, mvert->co);
mul_m4_v3(hairmat, mvert->co);
mvert++;
if(k) {
@ -3105,7 +3105,7 @@ static void save_hair(ParticleSimulationData *sim, float cfra){
PARTICLE_P;
int totpart;
Mat4Invert(ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
psys->lattice= psys_get_lattice(sim);
@ -3125,8 +3125,8 @@ static void save_hair(ParticleSimulationData *sim, float cfra){
key += pa->totkey;
/* convert from global to geometry space */
VecCopyf(key->co, pa->state.co);
Mat4MulVecfl(ob->imat, key->co);
copy_v3_v3(key->co, pa->state.co);
mul_m4_v3(ob->imat, key->co);
if(pa->totkey) {
VECSUB(key->co, key->co, root->co);
@ -3941,6 +3941,6 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
system_step(&sim, cfra);
/* save matrix for duplicators */
Mat4Invert(psys->imat, ob->obmat);
invert_m4_m4(psys->imat, ob->obmat);
}

@ -170,12 +170,12 @@ static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, f
dfra = cfra2 - cfra1;
VecMulf(keys[1].vel, dfra);
VecMulf(keys[2].vel, dfra);
mul_v3_fl(keys[1].vel, dfra);
mul_v3_fl(keys[2].vel, dfra);
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1);
VecMulf(keys->vel, 1.0f / dfra);
mul_v3_fl(keys->vel, 1.0f / dfra);
VECCOPY(bp->pos, keys->co);
VECCOPY(bp->vec, keys->vel);
@ -255,18 +255,18 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr
/* determine velocity from previous location */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
if(cfra > pa->prev_state.time) {
VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co);
VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec);
sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co);
mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec);
}
else {
VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co);
VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec);
sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co);
mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec);
}
}
/* determine rotation from velocity */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
vectoquat(pa->state.vel, OB_NEGX, OB_POSZ, pa->state.rot);
vec_to_quat( pa->state.rot,pa->state.vel, OB_NEGX, OB_POSZ);
}
}
static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data)
@ -292,18 +292,18 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f
/* determine velocity from previous location */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
if(keys[1].time > keys[2].time) {
VecSubf(keys[2].vel, keys[1].co, keys[2].co);
VecMulf(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec);
sub_v3_v3v3(keys[2].vel, keys[1].co, keys[2].co);
mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec);
}
else {
VecSubf(keys[2].vel, keys[2].co, keys[1].co);
VecMulf(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec);
sub_v3_v3v3(keys[2].vel, keys[2].co, keys[1].co);
mul_v3_fl(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec);
}
}
/* determine rotation from velocity */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
vectoquat(keys[2].vel, OB_NEGX, OB_POSZ, keys[2].rot);
vec_to_quat( keys[2].rot,keys[2].vel, OB_NEGX, OB_POSZ);
}
if(cfra > pa->time)
@ -311,13 +311,13 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f
dfra = cfra2 - cfra1;
VecMulf(keys[1].vel, dfra / frs_sec);
VecMulf(keys[2].vel, dfra / frs_sec);
mul_v3_fl(keys[1].vel, dfra / frs_sec);
mul_v3_fl(keys[2].vel, dfra / frs_sec);
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1);
QuatInterpol(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
interp_qt_qtqt(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
VecMulf(pa->state.vel, frs_sec / dfra);
mul_v3_fl(pa->state.vel, frs_sec / dfra);
pa->state.time = cfra;
}
@ -425,18 +425,18 @@ static int ptcache_totwrite_particle(void *psys_v)
// /* determine velocity from previous location */
// if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
// if(cfra > pa->prev_state.time) {
// VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co);
// VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec);
// sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co);
// mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec);
// }
// else {
// VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co);
// VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec);
// sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co);
// mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec);
// }
// }
//
// /* determine rotation from velocity */
// if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
// vectoquat(pa->state.vel, OB_POSX, OB_POSZ, pa->state.rot);
// vec_to_quat( pa->state.rot,pa->state.vel, OB_POSX, OB_POSZ);
// }
//}
//static void ptcache_interpolate_particle_stream(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data)
@ -461,13 +461,13 @@ static int ptcache_totwrite_particle(void *psys_v)
//
// dfra = cfra2 - cfra1;
//
// VecMulf(keys[1].vel, dfra / frs_sec);
// VecMulf(keys[2].vel, dfra / frs_sec);
// mul_v3_fl(keys[1].vel, dfra / frs_sec);
// mul_v3_fl(keys[2].vel, dfra / frs_sec);
//
// psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1);
// QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra);
// interp_qt_qtqt(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra);
//
// VecMulf(pa->state.vel, frs_sec / dfra);
// mul_v3_fl(pa->state.vel, frs_sec / dfra);
//
// pa->state.time = cfra;
//}
@ -525,12 +525,12 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo
dfra = cfra2 - cfra1;
VecMulf(keys[1].vel, dfra);
VecMulf(keys[2].vel, dfra);
mul_v3_fl(keys[1].vel, dfra);
mul_v3_fl(keys[2].vel, dfra);
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1);
VecMulf(keys->vel, 1.0f / dfra);
mul_v3_fl(keys->vel, 1.0f / dfra);
VECCOPY(vert->x, keys->co);
VECCOPY(vert->v, keys->vel);

@ -89,7 +89,7 @@
#include "BPY_extern.h"
#endif
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
//XXX #include "nla.h"
@ -654,7 +654,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
/* handle dupli's */
if(dupob) {
Mat4CpyMat4(dupob->ob->obmat, dupob->mat);
copy_m4_m4(dupob->ob->obmat, dupob->mat);
(*base)->flag |= OB_FROMDUPLI;
*ob= dupob->ob;
@ -667,7 +667,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
(*base)->flag &= ~OB_FROMDUPLI;
for(dupob= duplilist->first; dupob; dupob= dupob->next) {
Mat4CpyMat4(dupob->ob->obmat, dupob->omat);
copy_m4_m4(dupob->ob->obmat, dupob->omat);
}
free_object_duplilist(duplilist);

@ -38,7 +38,7 @@
#include "DNA_sequence_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_global.h"
#include "BKE_plugin_types.h"

@ -53,7 +53,7 @@
#include "BKE_mesh.h"
#include "BKE_tessmesh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
#include "BLI_editVert.h"
@ -117,31 +117,31 @@ DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDat
void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float target[4][4])
{
float itarget[4][4];
Mat4Invert(itarget, target);
Mat4MulSerie(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0);
Mat4Invert(data->target2local, data->local2target);
invert_m4_m4(itarget, target);
mul_serie_m4(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0);
invert_m4_m4(data->target2local, data->local2target);
}
void space_transform_apply(const SpaceTransform *data, float *co)
{
VecMat4MulVecfl(co, ((SpaceTransform*)data)->local2target, co);
mul_v3_m4v3(co, ((SpaceTransform*)data)->local2target, co);
}
void space_transform_invert(const SpaceTransform *data, float *co)
{
VecMat4MulVecfl(co, ((SpaceTransform*)data)->target2local, co);
mul_v3_m4v3(co, ((SpaceTransform*)data)->target2local, co);
}
static void space_transform_apply_normal(const SpaceTransform *data, float *no)
{
Mat4Mul3Vecfl( ((SpaceTransform*)data)->local2target, no);
Normalize(no); // TODO: could we just determine de scale value from the matrix?
mul_mat3_m4_v3( ((SpaceTransform*)data)->local2target, no);
normalize_v3(no); // TODO: could we just determine de scale value from the matrix?
}
static void space_transform_invert_normal(const SpaceTransform *data, float *no)
{
Mat4Mul3Vecfl(((SpaceTransform*)data)->target2local, no);
Normalize(no); // TODO: could we just determine de scale value from the matrix?
mul_mat3_m4_v3(((SpaceTransform*)data)->target2local, no);
normalize_v3(no); // TODO: could we just determine de scale value from the matrix?
}
/*
@ -224,7 +224,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
VECCOPY(tmp_co, nearest.co);
space_transform_invert(&calc->local2target, tmp_co);
VecLerpf(co, co, tmp_co, weight); //linear interpolation
interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation
}
}
@ -259,7 +259,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
space_transform_apply_normal( transf, tmp_no );
no = tmp_no;
hit_tmp.dist *= Mat4ToScalef( ((SpaceTransform*)transf)->local2target );
hit_tmp.dist *= mat4_to_scale( ((SpaceTransform*)transf)->local2target );
}
else
{
@ -286,7 +286,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
space_transform_invert( transf, hit_tmp.co );
space_transform_invert_normal( transf, hit_tmp.no );
hit_tmp.dist = VecLenf( (float*)vert, hit_tmp.co );
hit_tmp.dist = len_v3v3( (float*)vert, hit_tmp.co );
}
memcpy(hit, &hit_tmp, sizeof(hit_tmp) );
@ -332,7 +332,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S
if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f;
if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f;
Normalize(proj_axis);
normalize_v3(proj_axis);
//Invalid projection direction
if(INPR(proj_axis, proj_axis) < FLT_EPSILON)
@ -365,7 +365,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S
{
VECCOPY(tmp_co, calc->vert[i].co);
if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL)
NormalShortToFloat(tmp_no, calc->vert[i].no);
normal_short_to_float_v3(tmp_no, calc->vert[i].no);
else
VECCOPY(tmp_no, proj_axis);
}
@ -404,7 +404,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S
if(hit.index != -1)
{
VecLerpf(co, co, hit.co, weight);
interp_v3_v3v3(co, co, hit.co, weight);
}
}
}
@ -487,14 +487,14 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
float dist = sasqrt( nearest.dist );
if(dist > FLT_EPSILON)
VecLerpf(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation
interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation
else
VECCOPY( tmp_co, nearest.co );
}
//Convert the coordinates back to mesh coordinates
space_transform_invert(&calc->local2target, tmp_co);
VecLerpf(co, co, tmp_co, weight); //linear interpolation
interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation
}
}

@ -35,7 +35,7 @@
#include "BKE_lattice.h"
#include "BKE_deform.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_shrinkwrap.h"
#include <string.h>
@ -171,8 +171,8 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s
}
else
{
Mat4CpyMat4(transf->local2target, smd->origin->obmat);
Mat4Invert(transf->target2local, transf->local2target);
copy_m4_m4(transf->local2target, smd->origin->obmat);
invert_m4_m4(transf->target2local, transf->local2target);
}
}
@ -246,7 +246,7 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s
axis_limit(limit_axis, smd_limit, co, dcut);
simpleDeform_callback(smd_factor, dcut, co); //Apply deform
VecLerpf(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation
interp_v3_v3v3(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation
if(transf) space_transform_invert(transf, vertexCos[i]);
}

@ -30,7 +30,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_sketch.h"
#include "BKE_utildefines.h"
@ -73,7 +73,7 @@ void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no)
if (no)
{
VECCOPY(pt->no, no);
Normalize(pt->no);
normalize_v3(pt->no);
}
else
{
@ -235,7 +235,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f
total = end - start;
VecSubf(delta_p, p_end, p_start);
sub_v3_v3v3(delta_p, p_end, p_start);
prev = stk->points + start;
next = stk->points + end;
@ -259,8 +259,8 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f
float *p = stk->points[start + 1 + i].p;
VECCOPY(p, delta_p);
VecMulf(p, delta);
VecAddf(p, p, p_start);
mul_v3_fl(p, delta);
add_v3_v3v3(p, p, p_start);
}
}
@ -320,9 +320,9 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end)
VECCOPY(normal, stk->points[start].no);
VecSubf(distance, stk->points[end].p, stk->points[start].p);
Projf(normal, distance, normal);
limit = Normalize(normal);
sub_v3_v3v3(distance, stk->points[end].p, stk->points[start].p);
project_v3_v3v3(normal, distance, normal);
limit = normalize_v3(normal);
for (i = 1; i < total - 1; i++)
{
@ -330,14 +330,14 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end)
float offset[3];
float *p = stk->points[start + i].p;
VecSubf(distance, p, stk->points[start].p);
Projf(distance, distance, normal);
sub_v3_v3v3(distance, p, stk->points[start].p);
project_v3_v3v3(distance, distance, normal);
VECCOPY(offset, normal);
VecMulf(offset, d);
mul_v3_fl(offset, d);
VecSubf(p, p, distance);
VecAddf(p, p, offset);
sub_v3_v3v3(p, p, distance);
add_v3_v3v3(p, p, offset);
}
}

@ -44,7 +44,7 @@
#include "BLI_rand.h"
#include "BLI_jitter.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
@ -150,7 +150,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive
float tmp[3];
VECCOPY(tmp, verts[i].co);
Mat4MulVecfl(ob->obmat, tmp);
mul_m4_v3(ob->obmat, tmp);
// min BB
min[0] = MIN2(min[0], tmp[0]);
@ -262,8 +262,8 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive
// bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6);
// copy obmat
// Mat4CpyMat4(smd->flow->mat, ob->obmat);
// Mat4CpyMat4(smd->flow->mat_old, ob->obmat);
// copy_m4_m4(smd->flow->mat, ob->obmat);
// copy_m4_m4(smd->flow->mat_old, ob->obmat);
}
*/
@ -283,8 +283,8 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive
SmokeCollSettings *scs = smd->coll;
// copy obmat
Mat4CpyMat4(scs->mat, ob->obmat);
Mat4CpyMat4(scs->mat_old, ob->obmat);
copy_m4_m4(scs->mat, ob->obmat);
copy_m4_m4(scs->mat_old, ob->obmat);
fill_scs_points(ob, dm, scs);
}
@ -332,7 +332,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
{
float tmpvec[3];
VECCOPY(tmpvec, mvert[i].co);
Mat4MulVecfl (ob->obmat, tmpvec);
mul_m4_v3(ob->obmat, tmpvec);
VECCOPY(&scs->points[i * 3], tmpvec);
}
@ -358,10 +358,10 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
VECSUB(side2, mvert[ mface[i].v3 ].co, mvert[ mface[i].v1 ].co);
}
Crossf(trinormorg, side1, side2);
Normalize(trinormorg);
cross_v3_v3v3(trinormorg, side1, side2);
normalize_v3(trinormorg);
VECCOPY(trinorm, trinormorg);
VecMulf(trinorm, 0.25 * cell_len);
mul_v3_fl(trinorm, 0.25 * cell_len);
for(j = 0; j <= divs1; j++)
{
@ -390,9 +390,9 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
VECCOPY(p3, mvert[ mface[i].v3 ].co);
}
VecMulf(p1, (1.0-uf-vf));
VecMulf(p2, uf);
VecMulf(p3, vf);
mul_v3_fl(p1, (1.0-uf-vf));
mul_v3_fl(p2, uf);
mul_v3_fl(p3, vf);
VECADD(p, p1, p2);
VECADD(p, p, p3);
@ -403,7 +403,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
// mMovPoints.push_back(p + trinorm);
VECCOPY(tmpvec, p);
VECADD(tmpvec, tmpvec, trinorm);
Mat4MulVecfl (ob->obmat, tmpvec);
mul_m4_v3(ob->obmat, tmpvec);
VECCOPY(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec);
newdivs++;
@ -413,7 +413,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
// mMovPoints.push_back(p - trinorm);
VECCOPY(tmpvec, p);
VECSUB(tmpvec, tmpvec, trinorm);
Mat4MulVecfl (ob->obmat, tmpvec);
mul_m4_v3(ob->obmat, tmpvec);
VECCOPY(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec);
newdivs++;
}
@ -466,11 +466,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int
int divs1=0, divs2=0, divs3=0;
VECCOPY(p0, verts[faces[i].v1].co);
Mat4MulVecfl (ob->obmat, p0);
mul_m4_v3(ob->obmat, p0);
VECCOPY(p1, verts[faces[i].v2].co);
Mat4MulVecfl (ob->obmat, p1);
mul_m4_v3(ob->obmat, p1);
VECCOPY(p2, verts[faces[i].v3].co);
Mat4MulVecfl (ob->obmat, p2);
mul_m4_v3(ob->obmat, p2);
VECSUB(side1, p1, p0);
VECSUB(side2, p2, p0);
@ -478,12 +478,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int
if(INPR(side1, side1) > fsTri*fsTri)
{
float tmp = Normalize(side1);
float tmp = normalize_v3(side1);
divs1 = (int)ceil(tmp/fsTri);
}
if(INPR(side2, side2) > fsTri*fsTri)
{
float tmp = Normalize(side2);
float tmp = normalize_v3(side2);
divs2 = (int)ceil(tmp/fsTri);
/*
@ -505,11 +505,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int
facecounter++;
VECCOPY(p0, verts[faces[i].v3].co);
Mat4MulVecfl (ob->obmat, p0);
mul_m4_v3(ob->obmat, p0);
VECCOPY(p1, verts[faces[i].v4].co);
Mat4MulVecfl (ob->obmat, p1);
mul_m4_v3(ob->obmat, p1);
VECCOPY(p2, verts[faces[i].v1].co);
Mat4MulVecfl (ob->obmat, p2);
mul_m4_v3(ob->obmat, p2);
VECSUB(side1, p1, p0);
VECSUB(side2, p2, p0);
@ -517,12 +517,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int
if(INPR(side1, side1) > fsTri*fsTri)
{
float tmp = Normalize(side1);
float tmp = normalize_v3(side1);
divs1 = (int)ceil(tmp/fsTri);
}
if(INPR(side2, side2) > fsTri*fsTri)
{
float tmp = Normalize(side2);
float tmp = normalize_v3(side2);
divs2 = (int)ceil(tmp/fsTri);
}
@ -849,7 +849,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue;
else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue;
// VECCOPY(pos, pa->state.co);
// Mat4MulVecfl (ob->imat, pos);
// mul_m4_v3(ob->imat, pos);
// 1. get corresponding cell
get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, cell, 0);
// check if cell is valid (in the domain boundary)
@ -1105,8 +1105,8 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
// rigid movement support
/*
Mat4CpyMat4(smd->flow->mat_old, smd->flow->mat);
Mat4CpyMat4(smd->flow->mat, ob->obmat);
copy_m4_m4(smd->flow->mat_old, smd->flow->mat);
copy_m4_m4(smd->flow->mat, ob->obmat);
*/
}
else if(scene->r.cfra < smd->time)
@ -1131,8 +1131,8 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
smd->coll->dm = CDDM_copy(dm, 1);
// rigid movement support
Mat4CpyMat4(smd->coll->mat_old, smd->coll->mat);
Mat4CpyMat4(smd->coll->mat, ob->obmat);
copy_m4_m4(smd->coll->mat_old, smd->coll->mat);
copy_m4_m4(smd->coll->mat, ob->obmat);
}
else if(scene->r.cfra < smd->time)
{
@ -1378,7 +1378,7 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int
float tmp[3];
VECSUB(tmp, pos, p0);
VecMulf(tmp, 1.0 / dx);
mul_v3_fl(tmp, 1.0 / dx);
if(correct)
{

@ -66,7 +66,7 @@ variables on the UI for now
#include "DNA_scene_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"
#include "BLI_cellalloc.h"
@ -266,7 +266,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
/* ah yeah, put the verices to global coords once */
/* and determine the ortho BB on the fly */
for(i=0; i < pccd_M->totvert; i++){
Mat4MulVecfl(ob->obmat, pccd_M->mvert[i].co);
mul_m4_v3(ob->obmat, pccd_M->mvert[i].co);
/* evaluate limits */
VECCOPY(v,pccd_M->mvert[i].co);
@ -363,7 +363,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm)
/* ah yeah, put the verices to global coords once */
/* and determine the ortho BB on the fly */
for(i=0; i < pccd_M->totvert; i++){
Mat4MulVecfl(ob->obmat, pccd_M->mvert[i].co);
mul_m4_v3(ob->obmat, pccd_M->mvert[i].co);
/* evaluate limits */
VECCOPY(v,pccd_M->mvert[i].co);
@ -1060,8 +1060,8 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
/* calculate face normal once again SIGH */
VECSUB(edge1, face_v1, face_v2);
VECSUB(edge2, face_v3, face_v2);
Crossf(d_nvect, edge2, edge1);
Normalize(d_nvect);
cross_v3_v3v3(d_nvect, edge2, edge1);
normalize_v3(d_nvect);
hash = vertexowner->soft->scratch->colliderhash;
@ -1104,14 +1104,14 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
while(a){
VECCOPY(nv1,mvert[a-1].co);
if(mprevvert){
VecMulf(nv1,time);
mul_v3_fl(nv1,time);
Vec3PlusStVec(nv1,(1.0f-time),mprevvert[a-1].co);
}
/* origin to face_v2*/
VECSUB(nv1, nv1, face_v2);
facedist = Inpf(nv1,d_nvect);
facedist = dot_v3v3(nv1,d_nvect);
if (ABS(facedist)<outerfacethickness){
if (point_in_tri_prism(nv1, face_v1,face_v2,face_v3) ){
if (isect_point_tri_prism_v3(nv1, face_v1,face_v2,face_v3) ){
float df;
if (facedist > 0){
df = (outerfacethickness-facedist)/outerfacethickness;
@ -1219,17 +1219,17 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa
VECCOPY(nv4,mvert[mface->v4].co);
}
if (mprevvert){
VecMulf(nv1,time);
mul_v3_fl(nv1,time);
Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co);
VecMulf(nv2,time);
mul_v3_fl(nv2,time);
Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co);
VecMulf(nv3,time);
mul_v3_fl(nv3,time);
Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co);
if (mface->v4){
VecMulf(nv4,time);
mul_v3_fl(nv4,time);
Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co);
}
}
@ -1238,12 +1238,12 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa
/* switch origin to be nv2*/
VECSUB(edge1, nv1, nv2);
VECSUB(edge2, nv3, nv2);
Crossf(d_nvect, edge2, edge1);
Normalize(d_nvect);
cross_v3_v3v3(d_nvect, edge2, edge1);
normalize_v3(d_nvect);
if (
LineIntersectsTriangle(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) ||
LineIntersectsTriangle(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) ||
LineIntersectsTriangle(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){
isect_line_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) ||
isect_line_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) ||
isect_line_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){
Vec3PlusStVec(force,-0.5f,d_nvect);
*damp=tune*ob->pd->pdef_sbdamp;
deflected = 2;
@ -1252,13 +1252,13 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa
/* switch origin to be nv4 */
VECSUB(edge1, nv3, nv4);
VECSUB(edge2, nv1, nv4);
Crossf(d_nvect, edge2, edge1);
Normalize(d_nvect);
cross_v3_v3v3(d_nvect, edge2, edge1);
normalize_v3(d_nvect);
if (
/* LineIntersectsTriangle(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) ||
/* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) ||
we did that edge allready */
LineIntersectsTriangle(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) ||
LineIntersectsTriangle(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){
isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) ||
isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){
Vec3PlusStVec(force,-0.5f,d_nvect);
*damp=tune*ob->pd->pdef_sbdamp;
deflected = 2;
@ -1381,7 +1381,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
aabbmax[1] = MAX2(edge_v1[1],edge_v2[1]);
aabbmax[2] = MAX2(edge_v1[2],edge_v2[2]);
el = VecLenf(edge_v1,edge_v2);
el = len_v3v3(edge_v1,edge_v2);
hash = vertexowner->soft->scratch->colliderhash;
ihash = BLI_ghashIterator_new(hash);
@ -1447,17 +1447,17 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
VECCOPY(nv4,mvert[mface->v4].co);
}
if (mprevvert){
VecMulf(nv1,time);
mul_v3_fl(nv1,time);
Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co);
VecMulf(nv2,time);
mul_v3_fl(nv2,time);
Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co);
VecMulf(nv3,time);
mul_v3_fl(nv3,time);
Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co);
if (mface->v4){
VecMulf(nv4,time);
mul_v3_fl(nv4,time);
Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co);
}
}
@ -1467,15 +1467,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
VECSUB(edge1, nv1, nv2);
VECSUB(edge2, nv3, nv2);
Crossf(d_nvect, edge2, edge1);
Normalize(d_nvect);
if ( LineIntersectsTriangle(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)){
cross_v3_v3v3(d_nvect, edge2, edge1);
normalize_v3(d_nvect);
if ( isect_line_tri_v3(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)){
float v1[3],v2[3];
float intrusiondepth,i1,i2;
VECSUB(v1, edge_v1, nv2);
VECSUB(v2, edge_v2, nv2);
i1 = Inpf(v1,d_nvect);
i2 = Inpf(v2,d_nvect);
i1 = dot_v3v3(v1,d_nvect);
i2 = dot_v3v3(v2,d_nvect);
intrusiondepth = -MIN2(i1,i2)/el;
Vec3PlusStVec(force,intrusiondepth,d_nvect);
*damp=ob->pd->pdef_sbdamp;
@ -1486,15 +1486,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
VECSUB(edge1, nv3, nv4);
VECSUB(edge2, nv1, nv4);
Crossf(d_nvect, edge2, edge1);
Normalize(d_nvect);
if (LineIntersectsTriangle( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){
cross_v3_v3v3(d_nvect, edge2, edge1);
normalize_v3(d_nvect);
if (isect_line_tri_v3( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){
float v1[3],v2[3];
float intrusiondepth,i1,i2;
VECSUB(v1, edge_v1, nv4);
VECSUB(v2, edge_v2, nv4);
i1 = Inpf(v1,d_nvect);
i2 = Inpf(v2,d_nvect);
i1 = dot_v3v3(v1,d_nvect);
i2 = dot_v3v3(v2,d_nvect);
intrusiondepth = -MIN2(i1,i2)/el;
@ -1532,7 +1532,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
if (ob->softflag & OB_SB_EDGECOLL){
if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos,
&damp,feedback,ob->lay,ob,timenow)){
VecAddf(bs->ext_force,bs->ext_force,feedback);
add_v3_v3v3(bs->ext_force,bs->ext_force,feedback);
bs->flag |= BSF_INTERSECT;
//bs->cf=damp;
bs->cf=sb->choke*0.01f;
@ -1551,30 +1551,30 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
EffectedPoint epoint;
float speed[3]={0.0f,0.0f,0.0f};
float pos[3];
VecMidf(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos);
VecMidf(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec);
mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos);
mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec);
pd_point_from_soft(scene, pos, vel, -1, &epoint);
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
VecMulf(speed,windfactor);
VecAddf(vel,vel,speed);
mul_v3_fl(speed,windfactor);
add_v3_v3v3(vel,vel,speed);
}
/* media in rest */
else{
VECADD(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec);
}
f = Normalize(vel);
f = normalize_v3(vel);
f = -0.0001f*f*f*sb->aeroedge;
/* (todo) add a nice angle dependant function done for now BUT */
/* still there could be some nice drag/lift function, but who needs it */
VECSUB(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos);
Projf(pr,vel,sp);
project_v3_v3v3(pr,vel,sp);
VECSUB(vel,vel,pr);
Normalize(vel);
normalize_v3(vel);
if (ob->softflag & OB_SB_AERO_ANGLE){
Normalize(sp);
Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(Inpf(vel,sp))),vel);
normalize_v3(sp);
Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel);
}
else{
Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files
@ -1672,15 +1672,15 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl
{
float mindist,cp;
int winner =1;
mindist = ABS(Inpf(pos,a));
mindist = ABS(dot_v3v3(pos,a));
cp = ABS(Inpf(pos,b));
cp = ABS(dot_v3v3(pos,b));
if ( mindist < cp ){
mindist = cp;
winner =2;
}
cp = ABS(Inpf(pos,c));
cp = ABS(dot_v3v3(pos,c));
if (mindist < cp ){
mindist = cp;
winner =3;
@ -1806,17 +1806,17 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
VECSUB(vv4,nv4,mprevvert[mface->v4].co);
}
VecMulf(nv1,time);
mul_v3_fl(nv1,time);
Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co);
VecMulf(nv2,time);
mul_v3_fl(nv2,time);
Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co);
VecMulf(nv3,time);
mul_v3_fl(nv3,time);
Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co);
if (mface->v4){
VecMulf(nv4,time);
mul_v3_fl(nv4,time);
Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co);
}
}
@ -1827,14 +1827,14 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
VECSUB(edge2, nv3, nv2);
VECSUB(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */
Crossf(d_nvect, edge2, edge1);
n_mag = Normalize(d_nvect);
facedist = Inpf(dv1,d_nvect);
cross_v3_v3v3(d_nvect, edge2, edge1);
n_mag = normalize_v3(d_nvect);
facedist = dot_v3v3(dv1,d_nvect);
// so rules are
//
if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){
if (point_in_tri_prism(opco, nv1, nv2, nv3) ){
if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ){
force_mag_norm =(float)exp(-ee*facedist);
if (facedist > outerfacethickness*ff)
force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness);
@ -1864,12 +1864,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
VECSUB(edge2, nv1, nv4);
VECSUB(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */
Crossf(d_nvect, edge2, edge1);
n_mag = Normalize(d_nvect);
facedist = Inpf(dv1,d_nvect);
cross_v3_v3v3(d_nvect, edge2, edge1);
n_mag = normalize_v3(d_nvect);
facedist = dot_v3v3(dv1,d_nvect);
if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){
if (point_in_tri_prism(opco, nv1, nv3, nv4) ){
if (isect_point_tri_prism_v3(opco, nv1, nv3, nv4) ){
force_mag_norm =(float)exp(-ee*facedist);
if (facedist > outerfacethickness*ff)
force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness);
@ -1899,45 +1899,45 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
{ // see if 'outer' hits an edge
float dist;
PclosestVL3Dfl(ve, opco, nv1, nv2);
closest_to_line_segment_v3(ve, opco, nv1, nv2);
VECSUB(ve,opco,ve);
dist = Normalize(ve);
dist = normalize_v3(ve);
if ((dist < outerfacethickness)&&(dist < mindistedge )){
VECCOPY(coledge,ve);
mindistedge = dist,
deflected=1;
}
PclosestVL3Dfl(ve, opco, nv2, nv3);
closest_to_line_segment_v3(ve, opco, nv2, nv3);
VECSUB(ve,opco,ve);
dist = Normalize(ve);
dist = normalize_v3(ve);
if ((dist < outerfacethickness)&&(dist < mindistedge )){
VECCOPY(coledge,ve);
mindistedge = dist,
deflected=1;
}
PclosestVL3Dfl(ve, opco, nv3, nv1);
closest_to_line_segment_v3(ve, opco, nv3, nv1);
VECSUB(ve,opco,ve);
dist = Normalize(ve);
dist = normalize_v3(ve);
if ((dist < outerfacethickness)&&(dist < mindistedge )){
VECCOPY(coledge,ve);
mindistedge = dist,
deflected=1;
}
if (mface->v4){ /* quad */
PclosestVL3Dfl(ve, opco, nv3, nv4);
closest_to_line_segment_v3(ve, opco, nv3, nv4);
VECSUB(ve,opco,ve);
dist = Normalize(ve);
dist = normalize_v3(ve);
if ((dist < outerfacethickness)&&(dist < mindistedge )){
VECCOPY(coledge,ve);
mindistedge = dist,
deflected=1;
}
PclosestVL3Dfl(ve, opco, nv1, nv4);
closest_to_line_segment_v3(ve, opco, nv1, nv4);
VECSUB(ve,opco,ve);
dist = Normalize(ve);
dist = normalize_v3(ve);
if ((dist < outerfacethickness)&&(dist < mindistedge )){
VECCOPY(coledge,ve);
mindistedge = dist,
@ -1975,12 +1975,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
}
BLI_ghashIterator_free(ihash);
if (cavel) VecMulf(avel,1.0f/(float)cavel);
if (cavel) mul_v3_fl(avel,1.0f/(float)cavel);
VECCOPY(vel,avel);
if (ci) *intrusion /= ci;
if (deflected){
VECCOPY(facenormal,force);
Normalize(facenormal);
normalize_v3(facenormal);
}
return deflected;
}
@ -2061,8 +2061,8 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo
}
/* do bp1 <--> bp2 elastic */
VecSubf(dir,bp1->pos,bp2->pos);
distance = Normalize(dir);
sub_v3_v3v3(dir,bp1->pos,bp2->pos);
distance = normalize_v3(dir);
if (bs->len < distance)
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
else
@ -2093,10 +2093,10 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo
Vec3PlusStVec(bp1->force,(bs->len - distance)*forcefactor,dir);
/* do bp1 <--> bp2 viscous */
VecSubf(dvel,bp1->vec,bp2->vec);
sub_v3_v3v3(dvel,bp1->vec,bp2->vec);
kd = sb->infrict * sb_fric_force_scale(ob);
absvel = Normalize(dvel);
projvel = Inpf(dir,dvel);
absvel = normalize_v3(dvel);
projvel = dot_v3v3(dir,dvel);
kd *= absvel * projvel;
Vec3PlusStVec(bp1->force,-kd,dir);
@ -2170,11 +2170,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) {
compare = (obp->colball + bp->colball);
VecSubf(def, bp->pos, obp->pos);
sub_v3_v3v3(def, bp->pos, obp->pos);
/* rather check the AABBoxes before ever calulating the real distance */
/* mathematically it is completly nuts, but performace is pretty much (3) times faster */
if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue;
distance = Normalize(def);
distance = normalize_v3(def);
if (distance < compare ){
/* exclude body points attached with a spring */
attached = 0;
@ -2187,16 +2187,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
if (!attached){
float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ;
VecMidf(velcenter, bp->vec, obp->vec);
VecSubf(dvel,velcenter,bp->vec);
VecMulf(dvel,bp->mass);
mid_v3_v3v3(velcenter, bp->vec, obp->vec);
sub_v3_v3v3(dvel,velcenter,bp->vec);
mul_v3_fl(dvel,bp->mass);
Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def);
Vec3PlusStVec(bp->force,sb->balldamp,dvel);
/* exploit force(a,b) == -force(b,a) part2/2 */
VecSubf(dvel,velcenter,obp->vec);
VecMulf(dvel,bp->mass);
sub_v3_v3v3(dvel,velcenter,obp->vec);
mul_v3_fl(dvel,bp->mass);
Vec3PlusStVec(obp->force,sb->balldamp,dvel);
Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def);
@ -2214,16 +2214,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
if(ob->softflag & OB_SB_GOAL) {
/* true elastic goal */
float ks,kd;
VecSubf(auxvect,bp->pos,bp->origT);
sub_v3_v3v3(auxvect,bp->pos,bp->origT);
ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ;
bp->force[0]+= -ks*(auxvect[0]);
bp->force[1]+= -ks*(auxvect[1]);
bp->force[2]+= -ks*(auxvect[2]);
/* calulate damping forces generated by goals*/
VecSubf(velgoal,bp->origS, bp->origE);
sub_v3_v3v3(velgoal,bp->origS, bp->origE);
kd = sb->goalfrict * sb_fric_force_scale(ob) ;
VecAddf(auxvect,velgoal,bp->vec);
add_v3_v3v3(auxvect,velgoal,bp->vec);
if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */
bp->force[0]-= kd * (auxvect[0]);
@ -2242,8 +2242,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){
float gravity[3];
VECCOPY(gravity, scene->physics_settings.gravity);
VecMulf(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */
VecAddf(bp->force, bp->force, gravity);
mul_v3_fl(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */
add_v3_v3v3(bp->force, bp->force, gravity);
}
/* particle field & vortex */
@ -2257,7 +2257,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
/* apply forcefield*/
VecMulf(force,fieldfactor* eval_sb_fric_force_scale);
mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale);
VECADD(bp->force, bp->force, force);
/* BP friction in moving media */
@ -2310,7 +2310,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
for(b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
if (do_springcollision || do_aero){
VecAddf(bp->force,bp->force,bs->ext_force);
add_v3_v3v3(bp->force,bp->force,bs->ext_force);
if (bs->flag & BSF_INTERSECT)
bp->choke = bs->cf;
@ -2479,7 +2479,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){
VECCOPY(gravity, scene->physics_settings.gravity);
VecMulf(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity);
mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity);
}
/* check conditions for various options */
@ -2539,13 +2539,13 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
//if ((bp->octantflag & obp->octantflag) == 0) continue;
compare = (obp->colball + bp->colball);
VecSubf(def, bp->pos, obp->pos);
sub_v3_v3v3(def, bp->pos, obp->pos);
/* rather check the AABBoxes before ever calulating the real distance */
/* mathematically it is completly nuts, but performace is pretty much (3) times faster */
if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue;
distance = Normalize(def);
distance = normalize_v3(def);
if (distance < compare ){
/* exclude body points attached with a spring */
attached = 0;
@ -2558,9 +2558,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
if (!attached){
float f = tune/(distance) + tune/(compare*compare)*distance - 2.0f*tune/compare ;
VecMidf(velcenter, bp->vec, obp->vec);
VecSubf(dvel,velcenter,bp->vec);
VecMulf(dvel,bp->mass);
mid_v3_v3v3(velcenter, bp->vec, obp->vec);
sub_v3_v3v3(dvel,velcenter,bp->vec);
mul_v3_fl(dvel,bp->mass);
Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def);
Vec3PlusStVec(bp->force,sb->balldamp,dvel);
@ -2590,8 +2590,8 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
}
/* exploit force(a,b) == -force(b,a) part2/2 */
VecSubf(dvel,velcenter,obp->vec);
VecMulf(dvel,(bp->mass+obp->mass)/2.0f);
sub_v3_v3v3(dvel,velcenter,obp->vec);
mul_v3_fl(dvel,(bp->mass+obp->mass)/2.0f);
Vec3PlusStVec(obp->force,sb->balldamp,dvel);
Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def);
@ -2610,7 +2610,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* do goal stuff */
if(ob->softflag & OB_SB_GOAL) {
/* true elastic goal */
VecSubf(auxvect,bp->pos,bp->origT);
sub_v3_v3v3(auxvect,bp->pos,bp->origT);
ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ;
bp->force[0]+= -ks*(auxvect[0]);
bp->force[1]+= -ks*(auxvect[1]);
@ -2625,9 +2625,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
/* calulate damping forces generated by goals*/
VecSubf(velgoal,bp->origS, bp->origE);
sub_v3_v3v3(velgoal,bp->origS, bp->origE);
kd = sb->goalfrict * sb_fric_force_scale(ob) ;
VecAddf(auxvect,velgoal,bp->vec);
add_v3_v3v3(auxvect,velgoal,bp->vec);
if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */
bp->force[0]-= kd * (auxvect[0]);
@ -2635,7 +2635,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->force[2]-= kd * (auxvect[2]);
if(nl_flags & NLF_BUILD){
//int ia =3*(sb->totpoint-a);
Normalize(auxvect);
normalize_v3(auxvect);
/* depending on my vel */
//dfdv_goal(ia,ia,kd*forcetime);
}
@ -2664,7 +2664,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
/* apply forcefield*/
VecMulf(force,fieldfactor* eval_sb_fric_force_scale);
mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale);
VECADD(bp->force, bp->force, force);
/* BP friction in moving media */
@ -2751,7 +2751,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
for(b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
if (do_springcollision || do_aero){
VecAddf(bp->force,bp->force,bs->ext_force);
add_v3_v3v3(bp->force,bp->force,bs->ext_force);
if (bs->flag & BSF_INTERSECT)
bp->choke = bs->cf;
@ -2883,7 +2883,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* the ( ... )' operator denotes derivate respective time */
/* the euler step for velocity then becomes */
/* v(t + dt) = v(t) + a(t) * dt */
VecMulf(bp->force,timeovermass);/* individual mass of node here */
mul_v3_fl(bp->force,timeovermass);/* individual mass of node here */
/* some nasty if's to have heun in here too */
VECCOPY(dv,bp->force);
@ -2910,17 +2910,17 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* so here is (x)'= v(elocity) */
/* the euler step for location then becomes */
/* x(t + dt) = x(t) + v(t~) * dt */
VecMulf(dx,forcetime);
mul_v3_fl(dx,forcetime);
/* the freezer coming sooner or later */
/*
if ((Inpf(dx,dx)<freezeloc )&&(Inpf(bp->force,bp->force)<freezeforce )){
if ((dot_v3v3(dx,dx)<freezeloc )&&(dot_v3v3(bp->force,bp->force)<freezeforce )){
bp->frozen /=2;
}
else{
bp->frozen =MIN2(bp->frozen*1.05f,1.0f);
}
VecMulf(dx,bp->frozen);
mul_v3_fl(dx,bp->frozen);
*/
/* again some nasty if's to have heun in here too */
if (mode ==1){
@ -2941,10 +2941,10 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
we don't want to end up in deep space so we add some <viscosity>
to balance that out */
if (bp->choke2 > 0.0f){
VecMulf(bp->vec,(1.0f - bp->choke2));
mul_v3_fl(bp->vec,(1.0f - bp->choke2));
}
if (bp->choke > 0.0f){
VecMulf(bp->vec,(1.0f - bp->choke));
mul_v3_fl(bp->vec,(1.0f - bp->choke));
}
}
@ -2960,7 +2960,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
if (bp->flag & SBF_DOFUZZY) fuzzy =1;
} /*for*/
if (sb->totpoint) VecMulf(cm,1.0f/sb->totpoint);
if (sb->totpoint) mul_v3_fl(cm,1.0f/sb->totpoint);
if (sb->scratch){
VECCOPY(sb->scratch->aabbmin,aabbmin);
VECCOPY(sb->scratch->aabbmax,aabbmax);
@ -3101,7 +3101,7 @@ static void apply_spring_memory(Object *ob)
bs = &sb->bspring[a];
bp1 =&sb->bpoint[bs->v1];
bp2 =&sb->bpoint[bs->v2];
l = VecLenf(bp1->pos,bp2->pos);
l = len_v3v3(bp1->pos,bp2->pos);
r = bs->len/l;
if (( r > 1.05f) || (r < 0.95)){
bs->len = ((100.0f - b) * bs->len + b*l)/100.0f;
@ -3193,7 +3193,7 @@ static void springs_from_mesh(Object *ob)
bp= ob->soft->bpoint;
for(a=0; a<me->totvert; a++, bp++) {
VECCOPY(bp->origS, me->mvert[a].co);
Mat4MulVecfl(ob->obmat, bp->origS);
mul_m4_v3(ob->obmat, bp->origS);
}
}
@ -3204,7 +3204,7 @@ static void springs_from_mesh(Object *ob)
}
for(a=0; a<sb->totspring; a++) {
BodySpring *bs = &sb->bspring[a];
bs->len= scale*VecLenf(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS);
bs->len= scale*len_v3v3(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS);
}
}
}
@ -3342,10 +3342,10 @@ static float globallen(float *v1,float *v2,Object *ob)
{
float p1[3],p2[3];
VECCOPY(p1,v1);
Mat4MulVecfl(ob->obmat, p1);
mul_m4_v3(ob->obmat, p1);
VECCOPY(p2,v2);
Mat4MulVecfl(ob->obmat, p2);
return VecLenf(p1,p2);
mul_m4_v3(ob->obmat, p2);
return len_v3v3(p1,p2);
}
static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *ob)
@ -3574,12 +3574,12 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
int a;
/* inverse matrix is not uptodate... */
Mat4Invert(ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
for(a=0; a<numVerts; a++, bp++) {
VECCOPY(vertexCos[a], bp->pos);
if(local==0)
Mat4MulVecfl(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
}
}
@ -3707,7 +3707,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo
/* copy the position of the goals at desired end time */
VECCOPY(bp->origE, vertexCos[a]);
/* vertexCos came from local world, go global */
Mat4MulVecfl(ob->obmat, bp->origE);
mul_m4_v3(ob->obmat, bp->origE);
/* just to be save give bp->origT a defined value
will be calulated in interpolate_exciter()*/
VECCOPY(bp->origT, bp->origE);
@ -3721,7 +3721,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
for(a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
VECCOPY(bp->pos, vertexCos[a]);
Mat4MulVecfl(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
VECCOPY(bp->origS, bp->pos);
VECCOPY(bp->origE, bp->pos);
VECCOPY(bp->origT, bp->pos);

@ -55,7 +55,7 @@
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_linklist.h"
#include "BLI_memarena.h"
#include "BLI_edgehash.h"
@ -671,7 +671,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh,
#if 0
DM_interp_vert_data(dm, result, vertIdx, weight[0][0], numVerts, i);
#endif
VecCopyf(mvert->co, CCS_getFaceCenterData(f));
copy_v3_v3(mvert->co, CCS_getFaceCenterData(f));
*origIndex = ORIGINDEX_NONE;
++mvert;
++origIndex;
@ -696,7 +696,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh,
DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i);
#endif
VecCopyf(mvert->co,
copy_v3_v3(mvert->co,
CCS_getFaceGridEdgeData(ss, f, S, x));
*origIndex = ORIGINDEX_NONE;
@ -726,7 +726,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh,
DM_interp_vert_data(dm, result, vertIdx, w, numVerts, i);
#endif
VecCopyf(mvert->co,
copy_v3_v3(mvert->co,
CCS_getFaceGridData(ss, f, S, x, y));
*origIndex = ORIGINDEX_NONE;
++mvert;
@ -758,7 +758,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh,
w2[0] = 1 - w2[1];
DM_interp_vert_data(dm, result, vertIdx, w2, 2, i);
VecCopyf(mvert->co, CCS_getEdgeData(ss, e, x));
copy_v3_v3(mvert->co, CCS_getEdgeData(ss, e, x));
*origIndex = ORIGINDEX_NONE;
++mvert;
++origIndex;
@ -776,7 +776,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh,
vertIdx = GET_INT_FROM_POINTER(CCS_getVertVertHandle(v));
DM_copy_vert_data(dm, result, vertIdx, i, 1);
VecCopyf(mvert->co, CCS_getVertData(ss, v));
copy_v3_v3(mvert->co, CCS_getVertData(ss, v));
*((int*)CCS_getVertUserData(ss, v)) = i;
*origIndex = cgdm_getVertMapIndex(ss, v);
@ -1156,19 +1156,19 @@ static void cgdm_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
offset = vertNum - cgdm->faceMap[i].startVert;
if(offset < 1) {
VecCopyf(mv->co, CCS_getFaceCenterData(f));
copy_v3_v3(mv->co, CCS_getFaceCenterData(f));
} else if(offset < gridSideEnd) {
offset -= 1;
grid = offset / gridSideVerts;
x = offset % gridSideVerts + 1;
VecCopyf(mv->co, CCS_getFaceGridEdgeData(ss, f, grid, x));
copy_v3_v3(mv->co, CCS_getFaceGridEdgeData(ss, f, grid, x));
} else if(offset < gridInternalEnd) {
offset -= gridSideEnd;
grid = offset / gridInternalVerts;
offset %= gridInternalVerts;
y = offset / gridSideVerts + 1;
x = offset % gridSideVerts + 1;
VecCopyf(mv->co, CCS_getFaceGridData(ss, f, grid, x, y));
copy_v3_v3(mv->co, CCS_getFaceGridData(ss, f, grid, x, y));
}
} else if((vertNum < cgdm->vertMap[0].startVert) && (CCS_getNumEdges(ss) > 0)) {
/* this vert comes from edge data */
@ -1183,14 +1183,14 @@ static void cgdm_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
e = cgdm->edgeMap[i].edge;
x = vertNum - cgdm->edgeMap[i].startVert + 1;
VecCopyf(mv->co, CCS_getEdgeData(ss, e, x));
copy_v3_v3(mv->co, CCS_getEdgeData(ss, e, x));
} else {
/* this vert comes from vert data */
CCVert *v;
i = vertNum - cgdm->vertMap[0].startVert;
v = cgdm->vertMap[i].vert;
VecCopyf(mv->co, CCS_getVertData(ss, v));
copy_v3_v3(mv->co, CCS_getVertData(ss, v));
}
}
@ -1331,11 +1331,11 @@ static void cgdm_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
CCFace *f = cgdm->faceMap[index].face;
int x, y, S, numVerts = CCS_getFaceNumVerts(f);
VecCopyf(mvert[i++].co, CCS_getFaceCenterData(f));
copy_v3_v3(mvert[i++].co, CCS_getFaceCenterData(f));
for(S = 0; S < numVerts; S++) {
for(x = 1; x < gridSize - 1; x++) {
VecCopyf(mvert[i++].co,
copy_v3_v3(mvert[i++].co,
CCS_getFaceGridEdgeData(ss, f, S, x));
}
}
@ -1343,7 +1343,7 @@ static void cgdm_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
for(S = 0; S < numVerts; S++) {
for(y = 1; y < gridSize - 1; y++) {
for(x = 1; x < gridSize - 1; x++) {
VecCopyf(mvert[i++].co,
copy_v3_v3(mvert[i++].co,
CCS_getFaceGridData(ss, f, S, x, y));
}
}
@ -1356,7 +1356,7 @@ static void cgdm_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
int x;
for(x = 1; x < edgeSize - 1; x++) {
VecCopyf(mvert[i++].co, CCS_getEdgeData(ss, e, x));
copy_v3_v3(mvert[i++].co, CCS_getEdgeData(ss, e, x));
}
}
@ -1364,7 +1364,7 @@ static void cgdm_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
for(index = 0; index < totvert; index++) {
CCVert *v = cgdm->vertMap[index].vert;
VecCopyf(mvert[i].co, CCS_getVertData(ss, v));
copy_v3_v3(mvert[i].co, CCS_getVertData(ss, v));
i++;
}
@ -1699,18 +1699,18 @@ static void cgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) {
CCFace *f = faceMap2[index];
int x, y, S, numVerts = CCS_getFaceNumVerts(f);
VecCopyf(cos[i++], CCS_getFaceCenterData(f));
copy_v3_v3(cos[i++], CCS_getFaceCenterData(f));
for (S=0; S<numVerts; S++) {
for (x=1; x<gridSize-1; x++) {
VecCopyf(cos[i++], CCS_getFaceGridEdgeData(ss, f, S, x));
copy_v3_v3(cos[i++], CCS_getFaceGridEdgeData(ss, f, S, x));
}
}
for (S=0; S<numVerts; S++) {
for (y=1; y<gridSize-1; y++) {
for (x=1; x<gridSize-1; x++) {
VecCopyf(cos[i++], CCS_getFaceGridData(ss, f, S, x, y));
copy_v3_v3(cos[i++], CCS_getFaceGridData(ss, f, S, x, y));
}
}
}
@ -1721,13 +1721,13 @@ static void cgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) {
int x;
for (x=1; x<edgeSize-1; x++) {
VecCopyf(cos[i++], CCS_getEdgeData(ss, e, x));
copy_v3_v3(cos[i++], CCS_getEdgeData(ss, e, x));
}
}
for (index=0; index<totvert; index++) {
CCVert *v = vertMap2[index];
VecCopyf(cos[i++], CCS_getVertData(ss, v));
copy_v3_v3(cos[i++], CCS_getVertData(ss, v));
}
MEM_freeN(vertMap2);
@ -3333,17 +3333,17 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
for (i=0; i<N; i++) {
CCEdge *e = CCS_getVertEdge(v, i);
VecAddf(edge_sum, edge_sum, CCS_getEdgeData(ss, e, 1));
add_v3_v3v3(edge_sum, edge_sum, CCS_getEdgeData(ss, e, 1));
}
for (i=0; i<numFaces; i++) {
CCFace *f = CCS_getVertFace(v, i);
VecAddf(face_sum, face_sum, CCS_getFaceCenterData(f));
add_v3_v3v3(face_sum, face_sum, CCS_getFaceCenterData(f));
}
/* ad-hoc correction for boundary vertices, to at least avoid them
moving completely out of place (brecht) */
if(numFaces && numFaces != N)
VecMulf(face_sum, (float)N/(float)numFaces);
mul_v3_fl(face_sum, (float)N/(float)numFaces);
co = CCS_getVertData(ss, v);
positions_r[idx][0] = (co[0]*N*N + edge_sum[0]*4 + face_sum[0])/(N*(N+5));

@ -41,7 +41,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_kdopbvh.h"
@ -215,7 +215,7 @@ TexMapping *add_mapping(void)
texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f;
texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f;
Mat4One(texmap->mat);
unit_m4(texmap->mat);
return texmap;
}
@ -224,16 +224,16 @@ void init_mapping(TexMapping *texmap)
{
float eul[3], smat[3][3], rmat[3][3], mat[3][3];
SizeToMat3(texmap->size, smat);
size_to_mat3( smat,texmap->size);
eul[0]= (M_PI/180.0f)*texmap->rot[0];
eul[1]= (M_PI/180.0f)*texmap->rot[1];
eul[2]= (M_PI/180.0f)*texmap->rot[2];
EulToMat3(eul, rmat);
eul_to_mat3( rmat,eul);
Mat3MulMat3(mat, rmat, smat);
mul_m3_m3m3(mat, rmat, smat);
Mat4CpyMat3(texmap->mat, mat);
copy_m4_m3(texmap->mat, mat);
VECCOPY(texmap->mat[3], texmap->loc);
}

@ -35,7 +35,7 @@
#include "BLI_dynamiclist.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_verse.h"
#include "BKE_utildefines.h"
@ -114,16 +114,16 @@ static void recalculate_verseface_normals(VNode *vnode)
if(vface->vvert3) {
CalcNormFloat4(vface->vvert0->co, vface->vvert1->co,
vface->vvert2->co, vface->vvert3->co, vface->no);
VecAddf(vface->vvert3->no, vface->vvert3->no, vface->no);
add_v3_v3v3(vface->vvert3->no, vface->vvert3->no, vface->no);
}
else
CalcNormFloat(vface->vvert0->co, vface->vvert1->co,
vface->vvert2->co, vface->no);
/* calculate vertex normals ... it is averadge of all face normals using the vertex */
VecAddf(vface->vvert0->no, vface->vvert0->no, vface->no);
VecAddf(vface->vvert1->no, vface->vvert1->no, vface->no);
VecAddf(vface->vvert2->no, vface->vvert2->no, vface->no);
add_v3_v3v3(vface->vvert0->no, vface->vvert0->no, vface->no);
add_v3_v3v3(vface->vvert1->no, vface->vvert1->no, vface->no);
add_v3_v3v3(vface->vvert2->no, vface->vvert2->no, vface->no);
vface = vface->next;
}
@ -131,7 +131,7 @@ static void recalculate_verseface_normals(VNode *vnode)
/* we have to normalize all vertex normals */
vvert = vert_layer->dl.lb.first;
while(vvert) {
Normalize(vvert->no);
normalize_v3(vvert->no);
vvert = vvert->next;
}
}

@ -37,7 +37,7 @@
#include "BLI_dynamiclist.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BIF_verse.h"

@ -37,7 +37,7 @@
#include "BLI_dynamiclist.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BIF_verse.h"
@ -138,9 +138,9 @@ void send_verse_object_rotation(VNode *vnode)
float q[4] = {cos(-M_PI/4), -sin(-M_PI/4), 0, 0}, v[4], tmp[4];
/* inverse transformation to transformation in function cb_o_transform_rot_real32 */
QuatMul(v, ((VObjectData*)vnode->data)->quat, q);
mul_qt_qtqt(v, ((VObjectData*)vnode->data)->quat, q);
q[1]= sin(-M_PI/4);
QuatMul(tmp, q, v);
mul_qt_qtqt(tmp, q, v);
quat.x = tmp[1];
quat.y = tmp[2];
@ -465,9 +465,9 @@ static void cb_o_transform_rot_real32(
*
*, where v is original representation of rotation */
QuatMul(v, temp, q);
mul_qt_qtqt(v, temp, q);
q[1]= sin(M_PI/4); /* normal quaternion */
QuatMul(temp, q, v);
mul_qt_qtqt(temp, q, v);
if( (((VObjectData*)vnode->data)->quat[0] != temp[0]) ||
(((VObjectData*)vnode->data)->quat[1] != temp[1]) ||

@ -42,7 +42,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_utildefines.h"

@ -1,7 +1,7 @@
#undef TEST_ACTIVE
//#define ACTIVE 1
/**
* blenlib/BLI_arithb.h mar 2001 Nzc
* blenlib/BLI_math.h mar 2001 Nzc
*
* $Id$
*
@ -139,20 +139,21 @@ extern "C" {
{ 0.0, 0.0, 1.0}}
void CalcCent3f(float *cent, float *v1, float *v2, float *v3);
void CalcCent4f(float *cent, float *v1, float *v2, float *v3, float *v4);
void cent_tri_v3(float *cent, float *v1, float *v2, float *v3);
void cent_quad_v3(float *cent, float *v1, float *v2, float *v3, float *v4);
void Crossf(float *c, float *a, float *b);
void Projf(float *c, float *v1, float *v2);
void cross_v3_v3v3(float *c, float *a, float *b);
void project_v3_v3v3(float *c, float *v1, float *v2);
float Inpf(float *v1, float *v2);
float Inp2f(float *v1, float *v2);
float dot_v3v3(float *v1, float *v2);
float dot_v2v2(float *v1, float *v2);
float Normalize(float *n);
float Normalize2(float *n);
float normalize_v3(float *n);
float normalize_v2(float *n);
double normalize_dv3(double n[3]);
float Sqrt3f(float f);
double Sqrt3d(double d);
double sqrt3d(double d);
float saacos(float fac);
float saasin(float fac);
@ -161,12 +162,12 @@ float saacosf(float fac);
float saasinf(float fac);
float sasqrtf(float fac);
int FloatCompare(float *v1, float *v2, float limit);
int FloatCompare4(float *v1, float *v2, float limit);
float FloatLerpf(float target, float origin, float fac);
int compare_v3v3(float *v1, float *v2, float limit);
int compare_v4v4(float *v1, float *v2, float limit);
float interpf(float target, float origin, float fac);
float CalcNormFloat(float *v1, float *v2, float *v3, float *n);
float CalcNormFloat4(float *v1, float *v2, float *v3, float *v4, float *n);
float normal_tri_v3( float *n,float *v1, float *v2, float *v3);
float normal_quad_v3( float *n,float *v1, float *v2, float *v3, float *v4);
void CalcNormLong(int *v1, int *v2, int *v3, float *n);
/* CalcNormShort: is ook uitprodukt - (translates as 'is also out/cross product') */
@ -192,234 +193,234 @@ typedef enum eEulerRotationOrders {
/* NOTE: there are about 6 more entries when including duplicated entries too */
} eEulerRotationOrders;
void EulOToQuat(float eul[3], short order, float quat[4]);
void QuatToEulO(float quat[4], float eul[3], short order);
void eulO_to_quat( float quat[4],float eul[3], short order);
void quat_to_eulO( float eul[3], short order,float quat[4]);
void EulOToMat3(float eul[3], short order, float Mat[3][3]);
void EulOToMat4(float eul[3], short order, float Mat[4][4]);
void eulO_to_mat3( float Mat[3][3],float eul[3], short order);
void eulO_to_mat4( float Mat[4][4],float eul[3], short order);
void Mat3ToEulO(float Mat[3][3], float eul[3], short order);
void Mat4ToEulO(float Mat[4][4], float eul[3], short order);
void mat3_to_eulO( float eul[3], short order,float Mat[3][3]);
void mat4_to_eulO( float eul[3], short order,float Mat[4][4]);
void Mat3ToCompatibleEulO(float mat[3][3], float eul[3], float oldrot[3], short order);
void mat3_to_compatible_eulO( float eul[3], float oldrot[3], short order,float mat[3][3]);
void eulerO_rot(float beul[3], float ang, char axis, short order);
void rotate_eulO(float beul[3], short order, char axis, float ang);
/**
* @section Euler conversion routines (Blender XYZ)
*/
void EulToMat3(float *eul, float mat[][3]);
void EulToMat4(float *eul, float mat[][4]);
void eul_to_mat3( float mat[][3],float *eul);
void eul_to_mat4( float mat[][4],float *eul);
void Mat3ToEul(float tmat[][3], float *eul);
void Mat4ToEul(float tmat[][4],float *eul);
void mat3_to_eul( float *eul,float tmat[][3]);
void mat4_to_eul(float *eul,float tmat[][4]);
void EulToQuat(float *eul, float *quat);
void eul_to_quat( float *quat,float *eul);
void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot);
void EulToGimbalAxis(float gmat[][3], float *eul, short order);
void mat3_to_compatible_eul( float *eul, float *oldrot,float mat[][3]);
void eulO_to_gimbal_axis(float gmat[][3], float *eul, short order);
void compatible_eul(float *eul, float *oldrot);
void euler_rot(float *beul, float ang, char axis);
void rotate_eul(float *beul, char axis, float ang);
/**
* @section Quaternion arithmetic routines
*/
int QuatIsNul(float *q);
void QuatToEul(float *quat, float *eul);
void QuatOne(float *);
void QuatMul(float *, float *, float *);
void QuatMulVecf(float *q, float *v);
void QuatMulf(float *q, float f);
void QuatMulFac(float *q, float fac);
int is_zero_qt(float *q);
void quat_to_eul( float *eul,float *quat);
void unit_qt(float *);
void mul_qt_qtqt(float *, float *, float *);
void mul_qt_v3(float *q, float *v);
void mul_qt_fl(float *q, float f);
void mul_fac_qt_fl(float *q, float fac);
void NormalQuat(float *);
void VecRotToQuat(float *vec, float phi, float *quat);
void normalize_qt(float *);
void axis_angle_to_quat( float *quat,float *vec, float phi);
void QuatSub(float *q, float *q1, float *q2);
void QuatConj(float *q);
void QuatInv(float *q);
float QuatDot(float *q1, float *q2);
void QuatCopy(float *q1, float *q2);
void sub_qt_qtqt(float *q, float *q1, float *q2);
void conjugate_qt(float *q);
void invert_qt(float *q);
float dot_qtqt(float *q1, float *q2);
void copy_qt_qt(float *q1, float *q2);
void printquat(char *str, float q[4]);
void print_qt(char *str, float q[4]);
void QuatInterpol(float *result, float *quat1, float *quat2, float t);
void QuatAdd(float *result, float *quat1, float *quat2, float t);
void interp_qt_qtqt(float *result, float *quat1, float *quat2, float t);
void add_qt_qtqt(float *result, float *quat1, float *quat2, float t);
void QuatToMat3(float *q, float m[][3]);
void QuatToMat4(float *q, float m[][4]);
void quat_to_mat3( float m[][3],float *q);
void quat_to_mat4( float m[][4],float *q);
/**
* @section matrix multiplication and copying routines
*/
void Mat3MulFloat(float *m, float f);
void Mat4MulFloat(float *m, float f);
void Mat4MulFloat3(float *m, float f);
void mul_m3_fl(float *m, float f);
void mul_m4_fl(float *m, float f);
void mul_mat3_m4_fl(float *m, float f);
void Mat3Transp(float mat[][3]);
void Mat4Transp(float mat[][4]);
void transpose_m3(float mat[][3]);
void transpose_m4(float mat[][4]);
int Mat4Invert(float inverse[][4], float mat[][4]);
void Mat4InvertSimp(float inverse[][4], float mat[][4]);
void Mat4Inv(float *m1, float *m2);
void Mat4InvGG(float out[][4], float in[][4]);
void Mat3Inv(float m1[][3], float m2[][3]);
int invert_m4_m4(float inverse[][4], float mat[][4]);
void invert_m4_m4(float inverse[][4], float mat[][4]);
void invert_m4_m4(float *m1, float *m2);
void invert_m4_m4(float out[][4], float in[][4]);
void invert_m3_m3(float m1[][3], float m2[][3]);
void Mat3CpyMat4(float m1[][3],float m2[][4]);
void Mat4CpyMat3(float m1[][4], float m2[][3]);
void copy_m3_m4(float m1[][3],float m2[][4]);
void copy_m4_m3(float m1[][4], float m2[][3]);
void Mat3BlendMat3(float out[][3], float dst[][3], float src[][3], float srcweight);
void Mat4BlendMat4(float out[][4], float dst[][4], float src[][4], float srcweight);
void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweight);
void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], float srcweight);
float Det2x2(float a,float b,float c, float d);
float determinant_m2(float a,float b,float c, float d);
float Det3x3(
float determinant_m3(
float a1, float a2, float a3,
float b1, float b2, float b3,
float c1, float c2, float c3
);
float Det4x4(float m[][4]);
float determinant_m4(float m[][4]);
void Mat3Adj(float m1[][3], float m[][3]);
void Mat4Adj(float out[][4], float in[][4]);
void adjoint_m3_m3(float m1[][3], float m[][3]);
void adjoint_m4_m4(float out[][4], float in[][4]);
void Mat4MulMat4(float m1[][4], float m2[][4], float m3[][4]);
void mul_m4_m4m4(float m1[][4], float m2[][4], float m3[][4]);
void subMat4MulMat4(float *m1, float *m2, float *m3);
#ifndef TEST_ACTIVE
void Mat3MulMat3(float m1[][3], float m3[][3], float m2[][3]);
void mul_m3_m3m3(float m1[][3], float m3[][3], float m2[][3]);
#else
void Mat3MulMat3(float *m1, float *m3, float *m2);
void mul_m3_m3m3(float *m1, float *m3, float *m2);
#endif
void Mat4MulMat34(float (*m1)[4], float (*m3)[3], float (*m2)[4]);
void Mat4CpyMat4(float m1[][4], float m2[][4]);
void Mat4SwapMat4(float m1[][4], float m2[][4]);
void Mat3CpyMat3(float m1[][3], float m2[][3]);
void mul_m4_m3m4(float (*m1)[4], float (*m3)[3], float (*m2)[4]);
void copy_m4_m4(float m1[][4], float m2[][4]);
void swap_m4m4(float m1[][4], float m2[][4]);
void copy_m3_m3(float m1[][3], float m2[][3]);
void Mat3MulSerie(float answ[][3],
void mul_serie_m3(float answ[][3],
float m1[][3], float m2[][3], float m3[][3],
float m4[][3], float m5[][3], float m6[][3],
float m7[][3], float m8[][3]
);
void Mat4MulSerie(float answ[][4], float m1[][4],
void mul_serie_m4(float answ[][4], float m1[][4],
float m2[][4], float m3[][4], float m4[][4],
float m5[][4], float m6[][4], float m7[][4],
float m8[][4]
);
void Mat4Clr(float *m);
void Mat3Clr(float *m);
void zero_m4(float *m);
void zero_m3(float *m);
void Mat3One(float m[][3]);
void Mat4One(float m[][4]);
void unit_m3(float m[][3]);
void unit_m4(float m[][4]);
/* NOTE: These only normalise the matrix, they don't make it orthogonal */
void Mat3Ortho(float mat[][3]);
void Mat4Ortho(float mat[][4]);
void normalize_m3(float mat[][3]);
void normalize_m4(float mat[][4]);
int IsMat3Orthogonal(float mat[][3]);
void Mat3Orthogonal(float mat[][3], int axis); /* axis is the one to keep in place (assumes it is non-null) */
int IsMat4Orthogonal(float mat[][4]);
void Mat4Orthogonal(float mat[][4], int axis); /* axis is the one to keep in place (assumes it is non-null) */
int is_orthogonal_m3(float mat[][3]);
void orthogonalize_m3(float mat[][3], int axis); /* axis is the one to keep in place (assumes it is non-null) */
int is_orthogonal_m4(float mat[][4]);
void orthogonalize_m4(float mat[][4], int axis); /* axis is the one to keep in place (assumes it is non-null) */
void VecMat4MulVecfl(float *in, float mat[][4], float *vec);
void Mat4MulMat43(float (*m1)[4], float (*m3)[4], float (*m2)[3]);
void Mat3IsMat3MulMat4(float m1[][3], float m2[][3], float m3[][4]);
void mul_v3_m4v3(float *in, float mat[][4], float *vec);
void mul_m4_m4m3(float (*m1)[4], float (*m3)[4], float (*m2)[3]);
void mul_m3_m3m4(float m1[][3], float m2[][3], float m3[][4]);
void Mat4MulVec(float mat[][4],int *vec);
void Mat4MulVecfl(float mat[][4], float *vec);
void Mat4Mul3Vecfl(float mat[][4], float *vec);
void Mat4MulVec3Project(float mat[][4],float *vec);
void Mat4MulVec4fl(float mat[][4], float *vec);
void mul_m4_v3(float mat[][4], float *vec);
void mul_mat3_m4_v3(float mat[][4], float *vec);
void mul_project_m4_v4(float mat[][4],float *vec);
void mul_m4_v4(float mat[][4], float *vec);
void Mat3MulVec(float mat[][3],int *vec);
void Mat3MulVecfl(float mat[][3], float *vec);
void Mat3MulVecd(float mat[][3], double *vec);
void Mat3TransMulVecfl(float mat[][3], float *vec);
void mul_m3_v3(float mat[][3], float *vec);
void mul_m3_v3_double(float mat[][3], double *vec);
void mul_transposed_m3_v3(float mat[][3], float *vec);
void Mat3AddMat3(float m1[][3], float m2[][3], float m3[][3]);
void Mat4AddMat4(float m1[][4], float m2[][4], float m3[][4]);
void add_m3_m3m3(float m1[][3], float m2[][3], float m3[][3]);
void add_m4_m4m4(float m1[][4], float m2[][4], float m3[][4]);
void VecUpMat3old(float *vec, float mat[][3], short axis);
void VecUpMat3(float *vec, float mat[][3], short axis);
void VecCopyf(float *v1, float *v2);
void copy_v3_v3(float *v1, float *v2);
int VecLen(int *v1, int *v2);
float VecLenf(float v1[3], float v2[3]);
float VecLength(float *v);
void VecMulf(float *v1, float f);
void VecNegf(float *v1);
float len_v3v3(float v1[3], float v2[3]);
float len_v3(float *v);
void mul_v3_fl(float *v1, float f);
void negate_v3(float *v1);
int VecLenCompare(float *v1, float *v2, float limit);
int VecCompare(float *v1, float *v2, float limit);
int VecEqual(float *v1, float *v2);
int VecIsNull(float *v);
int compare_len_v3v3(float *v1, float *v2, float limit);
int compare_v3v3(float *v1, float *v2, float limit);
int equals_v3v3(float *v1, float *v2);
int is_zero_v3(float *v);
void printvecf(char *str,float v[3]);
void printvec4f(char *str, float v[4]);
void print_v3(char *str,float v[3]);
void print_v4(char *str, float v[4]);
void VecAddf(float *v, float *v1, float *v2);
void VecSubf(float *v, float *v1, float *v2);
void VecMulVecf(float *v, float *v1, float *v2);
void VecLerpf(float *target, const float *a, const float *b, const float t);
void VecLerp3f(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]);
void VecMidf(float *v, float *v1, float *v2);
void add_v3_v3v3(float *v, float *v1, float *v2);
void sub_v3_v3v3(float *v, float *v1, float *v2);
void mul_v3_v3v3(float *v, float *v1, float *v2);
void interp_v3_v3v3(float *target, const float *a, const float *b, const float t);
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]);
void mid_v3_v3v3(float *v, float *v1, float *v2);
void VecOrthoBasisf(float *v, float *v1, float *v2);
void ortho_basis_v3v3_v3( float *v1, float *v2,float *v);
float Vec2Lenf(float *v1, float *v2);
float Vec2Length(float *v);
void Vec2Mulf(float *v1, float f);
void Vec2Addf(float *v, float *v1, float *v2);
void Vec2Subf(float *v, float *v1, float *v2);
void Vec2Copyf(float *v1, float *v2);
void Vec2Lerpf(float *target, const float *a, const float *b, const float t);
void Vec2Lerp3f(float p[2], const float v1[2], const float v2[2], const float v3[2], const float w[3]);
float len_v2v2(float *v1, float *v2);
float len_v2(float *v);
void mul_v2_fl(float *v1, float f);
void add_v2_v2v2(float *v, float *v1, float *v2);
void sub_v2_v2v2(float *v, float *v1, float *v2);
void copy_v2_v2(float *v1, float *v2);
void interp_v2_v2v2(float *target, const float *a, const float *b, const float t);
void interp_v2_v2v2v2(float p[2], const float v1[2], const float v2[2], const float v3[2], const float w[3]);
void AxisAngleToQuat(float q[4], float axis[3], float angle);
void QuatToAxisAngle(float q[4], float axis[3], float *angle);
void AxisAngleToEulO(float axis[3], float angle, float eul[3], short order);
void EulOToAxisAngle(float eul[3], short order, float axis[3], float *angle);
void AxisAngleToMat3(float axis[3], float angle, float mat[3][3]);
void AxisAngleToMat4(float axis[3], float angle, float mat[4][4]);
void Mat3ToAxisAngle(float mat[3][3], float axis[3], float *angle);
void Mat4ToAxisAngle(float mat[4][4], float axis[3], float *angle);
void axis_angle_to_quat(float q[4], float axis[3], float angle);
void quat_to_axis_angle( float axis[3], float *angle,float q[4]);
void axis_angle_to_eulO( float eul[3], short order,float axis[3], float angle);
void eulO_to_axis_angle( float axis[3], float *angle,float eul[3], short order);
void axis_angle_to_mat3( float mat[3][3],float axis[3], float angle);
void axis_angle_to_mat4( float mat[4][4],float axis[3], float angle);
void mat3_to_axis_angle( float axis[3], float *angle,float mat[3][3]);
void mat4_to_axis_angle( float axis[3], float *angle,float mat[4][4]);
void Mat3ToVecRot(float mat[3][3], float axis[3], float *angle);
void Mat4ToVecRot(float mat[4][4], float axis[3], float *angle);
void VecRotToMat3(float *vec, float phi, float mat[][3]);
void VecRotToMat4(float *vec, float phi, float mat[][4]);
void mat3_to_vec_rot( float axis[3], float *angle,float mat[3][3]);
void mat4_to_vec_rot( float axis[3], float *angle,float mat[4][4]);
void vec_rot_to_mat3( float mat[][3],float *vec, float phi);
void vec_rot_to_mat4( float mat[][4],float *vec, float phi);
void RotationBetweenVectorsToQuat(float *q, float v1[3], float v2[3]);
void vectoquat(float *vec, short axis, short upflag, float *q);
void Mat3ToQuat_is_ok(float wmat[][3], float *q);
void rotation_between_vecs_to_quat(float *q, float v1[3], float v2[3]);
void vec_to_quat( float *q,float *vec, short axis, short upflag);
void mat3_to_quat_is_ok( float *q,float wmat[][3]);
void VecReflect(float *out, float *v1, float *v2);
void VecBisect3(float *v, float *v1, float *v2, float *v3);
float VecAngle2(float *v1, float *v2);
float VecAngle3(float *v1, float *v2, float *v3);
float NormalizedVecAngle2(float *v1, float *v2);
void reflect_v3_v3v3(float *out, float *v1, float *v2);
void bisect_v3_v3v3v3(float *v, float *v1, float *v2, float *v3);
float angle_v2v2(float *v1, float *v2);
float angle_v3v3v3(float *v1, float *v2, float *v3);
float angle_normalized_v3v3(float *v1, float *v2);
float Vec2Angle3(float *v1, float *v2, float *v3);
float NormalizedVecAngle2_2D(float *v1, float *v2);
float angle_v2v2v2(float *v1, float *v2, float *v3);
float angle_normalized_v2v2(float *v1, float *v2);
void NormalShortToFloat(float *out, short *in);
void NormalFloatToShort(short *out, float *in);
void normal_short_to_float_v3(float *out, short *in);
void normal_float_to_short_v3(short *out, float *in);
float DistVL2Dfl(float *v1, float *v2, float *v3);
float PdistVL2Dfl(float *v1, float *v2, float *v3);
float PdistVL3Dfl(float *v1, float *v2, float *v3);
void PclosestVL3Dfl(float *closest, float v1[3], float v2[3], float v3[3]);
float AreaF2Dfl(float *v1, float *v2, float *v3);
float AreaQ3Dfl(float *v1, float *v2, float *v3, float *v4);
float AreaT3Dfl(float *v1, float *v2, float *v3);
float AreaPoly3Dfl(int nr, float *verts, float *normal);
float dist_to_line_v2(float *v1, float *v2, float *v3);
float dist_to_line_segment_v2(float *v1, float *v2, float *v3);
float dist_to_line_segment_v3(float *v1, float *v2, float *v3);
void closest_to_line_segment_v3(float *closest, float v1[3], float v2[3], float v3[3]);
float area_tri_v2(float *v1, float *v2, float *v3);
float area_quad_v3(float *v1, float *v2, float *v3, float *v4);
float area_tri_v3(float *v1, float *v2, float *v3);
float area_poly_v3(int nr, float *verts, float *normal);
/* intersect Line-Line
return:
@ -428,18 +429,18 @@ float AreaPoly3Dfl(int nr, float *verts, float *normal);
1: exact intersection of segments
2: cross-intersection of segments
*/
extern short IsectLL2Df(float *v1, float *v2, float *v3, float *v4);
extern short IsectLL2Ds(short *v1, short *v2, short *v3, short *v4);
extern short isect_line_line_v2(float *v1, float *v2, float *v3, float *v4);
extern short isect_line_line_v2_short(short *v1, short *v2, short *v3, short *v4);
/*point in tri, 0 no intersection, 1 intersect */
int IsectPT2Df(float pt[2], float v1[2], float v2[2], float v3[2]);
int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]);
/* point in quad, 0 no intersection, 1 intersect */
int IsectPQ2Df(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2]);
int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2]);
/* interpolation weights of point in a triangle or quad, v4 may be NULL */
void InterpWeightsQ3Dfl(float *v1, float *v2, float *v3, float *v4, float *co, float *w);
void interp_weights_face_v3( float *w,float *v1, float *v2, float *v3, float *v4, float *co);
/* interpolation weights of point in a polygon with >= 3 vertices */
void MeanValueWeights(float v[][3], int n, float *co, float *w);
void interp_weights_poly_v3( float *w,float v[][3], int n, float *co);
void i_lookat(
float vx, float vy,
@ -474,66 +475,66 @@ int constrain_rgb(float *r, float *g, float *b);
unsigned int hsv_to_cpack(float h, float s, float v);
unsigned int rgb_to_cpack(float r, float g, float b);
void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);
void MinMaxRGB(short c[]);
void minmax_rgb(short c[]);
void VecStar(float mat[][3],float *vec);
void star_m3_v3(float mat[][3],float *vec);
short EenheidsMat(float mat[][3]);
void i_ortho(float left, float right, float bottom, float top, float nearClip, float farClip, float matrix[][4]);
void i_polarview(float dist, float azimuth, float incidence, float twist, float Vm[][4]);
void i_translate(float Tx, float Ty, float Tz, float mat[][4]);
void orthographic_m4( float matrix[][4],float left, float right, float bottom, float top, float nearClip, float farClip);
void polarview_m4( float Vm[][4],float dist, float azimuth, float incidence, float twist);
void translate_m4( float mat[][4],float Tx, float Ty, float Tz);
void i_multmatrix(float icand[][4], float Vm[][4]);
void i_rotate(float angle, char axis, float mat[][4]);
void rotate_m4( float mat[][4], char axis,float angle);
void MinMax3(float *min, float *max, float *vec);
void SizeToMat3(float *size, float mat[][3]);
void SizeToMat4(float *size, float mat[][4]);
void minmax_v3_v3v3(float *min, float *max, float *vec);
void size_to_mat3( float mat[][3],float *size);
void size_to_mat4( float mat[][4],float *size);
float Mat3ToScalef(float mat[][3]);
float Mat4ToScalef(float mat[][4]);
float mat3_to_scale(float mat[][3]);
float mat4_to_scale(float mat[][4]);
void printmatrix3(char *str, float m[][3]);
void printmatrix4(char *str, float m[][4]);
void print_m3(char *str, float m[][3]);
void print_m4(char *str, float m[][4]);
/* uit Sig.Proc.85 pag 253 */
void Mat3ToQuat(float wmat[][3], float *q);
void Mat4ToQuat(float m[][4], float *q);
void mat3_to_quat( float *q,float wmat[][3]);
void mat4_to_quat( float *q,float m[][4]);
void Mat3ToSize(float mat[][3], float *size);
void Mat4ToSize(float mat[][4], float *size);
void mat3_to_size( float *size,float mat[][3]);
void mat4_to_size( float *size,float mat[][4]);
void triatoquat(float *v1, float *v2, float *v3, float *quat);
void tri_to_quat( float *quat,float *v1, float *v2, float *v3);
void LocEulSizeToMat4(float mat[4][4], float loc[3], float eul[3], float size[3]);
void LocEulOSizeToMat4(float mat[4][4], float loc[3], float eul[3], float size[3], short rotOrder);
void LocQuatSizeToMat4(float mat[4][4], float loc[3], float quat[4], float size[3]);
void loc_eul_size_to_mat4(float mat[4][4], float loc[3], float eul[3], float size[3]);
void loc_eulO_size_to_mat4(float mat[4][4], float loc[3], float eul[3], float size[3], short rotOrder);
void loc_quat_size_to_mat4(float mat[4][4], float loc[3], float quat[4], float size[3]);
void tubemap(float x, float y, float z, float *u, float *v);
void spheremap(float x, float y, float z, float *u, float *v);
void map_to_tube( float *u, float *v,float x, float y, float z);
void map_to_sphere( float *u, float *v,float x, float y, float z);
int LineIntersectLine(float v1[3], float v2[3], float v3[3], float v4[3], float i1[3], float i2[3]);
int LineIntersectLineStrict(float v1[3], float v2[3], float v3[3], float v4[3], float vi[3], float *lambda);
int LineIntersectsTriangle(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv);
int RayIntersectsTriangle(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv);
int RayIntersectsTriangleThreshold(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold);
int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint);
int AxialLineIntersectsTriangle(int axis, float co1[3], float co2[3], float v0[3], float v1[3], float v2[3], float *lambda);
int AabbIntersectAabb(float min1[3], float max1[3], float min2[3], float max2[3]);
void VecfCubicInterpol(float *x1, float *v1, float *x2, float *v2, float t, float *x, float *v);
void PointInQuad2DUV(float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv);
void PointInFace2DUV(int isquad, float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv);
int IsPointInTri2D(float v1[2], float v2[2], float v3[2], float pt[2]);
int IsPointInTri2DInts(int x1, int y1, int x2, int y2, int a, int b);
int point_in_tri_prism(float p[3], float v1[3], float v2[3], float v3[3]);
int isect_line_line_v3(float v1[3], float v2[3], float v3[3], float v4[3], float i1[3], float i2[3]);
int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3], float vi[3], float *lambda);
int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv);
int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv);
int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold);
int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint);
int isect_axial_line_tri_v3(int axis, float co1[3], float co2[3], float v0[3], float v1[3], float v2[3], float *lambda);
int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3]);
void interp_cubic_v3( float *x, float *v,float *x1, float *v1, float *x2, float *v2, float t);
void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv);
void isect_point_face_uv_v2(int isquad, float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv);
int isect_point_tri_v2(float v1[2], float v2[2], float v3[2], float pt[2]);
int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b);
int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3]);
float lambda_cp_line_ex(float p[3], float l1[3], float l2[3], float cp[3]);
float closest_to_line_v3( float cp[3],float p[3], float l1[3], float l2[3]);
float AngleToLength(const float angle);
float shell_angle_to_dist(const float angle);
typedef struct DualQuat {
float quat[4];
@ -543,12 +544,12 @@ typedef struct DualQuat {
float scale_weight;
} DualQuat;
void Mat4ToDQuat(float basemat[][4], float mat[][4], DualQuat *dq);
void DQuatToMat4(DualQuat *dq, float mat[][4]);
void DQuatAddWeighted(DualQuat *dqsum, DualQuat *dq, float weight);
void DQuatNormalize(DualQuat *dq, float totweight);
void DQuatMulVecfl(DualQuat *dq, float *co, float mat[][3]);
void DQuatCpyDQuat(DualQuat *dq1, DualQuat *dq2);
void mat4_to_dquat( DualQuat *dq,float basemat[][4], float mat[][4]);
void dquat_to_mat4( float mat[][4],DualQuat *dq);
void add_weighted_dq_dq(DualQuat *dqsum, DualQuat *dq, float weight);
void normalize_dq(DualQuat *dq, float totweight);
void mul_v3m3_dq( float *co, float mat[][3],DualQuat *dq);
void copy_dq_dq(DualQuat *dq1, DualQuat *dq2);
/* Tangent stuff */
typedef struct VertexTangent {

@ -37,7 +37,7 @@
#include "BKE_utildefines.h"
#include "BLI_kdopbvh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#ifdef _OPENMP
#include <omp.h>
@ -1578,7 +1578,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float
VECCOPY(data.ray.direction, dir);
data.ray.radius = radius;
Normalize(data.ray.direction);
normalize_v3(data.ray.direction);
for(i=0; i<3; i++)
{
@ -1635,7 +1635,7 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl
data.ray.origin[1] = light_start[1];
data.ray.origin[2] = light_start[2];
Normalize(data.ray.direction);
normalize_v3(data.ray.direction);
VECCOPY(data.ray_dot_axis, data.ray.direction);
dist = ray_nearest_hit(&data, bv);

@ -34,7 +34,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_kdtree.h"
#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
@ -76,8 +76,8 @@ void BLI_kdtree_insert(KDTree *tree, int index, float *co, float *nor)
KDTreeNode *node= &tree->nodes[tree->totnode++];
node->index= index;
VecCopyf(node->co, co);
if(nor) VecCopyf(node->nor, nor);
copy_v3_v3(node->co, co);
if(nor) copy_v3_v3(node->nor, nor);
}
static KDTreeNode *kdtree_balance(KDTreeNode *nodes, int totnode, int axis)
@ -225,7 +225,7 @@ int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *
if(nearest) {
nearest->index= min_node->index;
nearest->dist= sqrt(min_dist);
VecCopyf(nearest->co, min_node->co);
copy_v3_v3(nearest->co, min_node->co);
}
if(stack != defaultstack)
@ -249,7 +249,7 @@ static void add_nearest(KDTreeNearest *ptn, int *found, int n, int index, float
ptn[i].index= index;
ptn[i].dist= dist;
VecCopyf(ptn[i].co, co);
copy_v3_v3(ptn[i].co, co);
}
/* finds the nearest n entries in tree to specified coordinates */
@ -366,7 +366,7 @@ static void add_in_range(KDTreeNearest **ptn, int found, int *totfoundstack, int
to->index = index;
to->dist = sqrt(dist);
VecCopyf(to->co, co);
copy_v3_v3(to->co, co);
}
int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KDTreeNearest **nearest)
{

File diff suppressed because it is too large Load Diff

@ -45,7 +45,7 @@
#include "BLI_vfontdata.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
//XXX #include "BIF_toolbox.h"
@ -256,11 +256,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
// VecLenf, see if there's a distance between the three points
// VecLenf again, to check the angle between the handles
// finally, check if one of them is a vector handle
if((DistVL2Dfl(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) &&
(VecLenf(bezt->vec[0], bezt->vec[1]) > 0.0001) &&
(VecLenf(bezt->vec[1], bezt->vec[2]) > 0.0001) &&
(VecLenf(bezt->vec[0], bezt->vec[2]) > 0.0002) &&
(VecLenf(bezt->vec[0], bezt->vec[2]) > MAX2(VecLenf(bezt->vec[0], bezt->vec[1]), VecLenf(bezt->vec[1], bezt->vec[2]))) &&
if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) &&
(len_v3v3(bezt->vec[0], bezt->vec[1]) > 0.0001) &&
(len_v3v3(bezt->vec[1], bezt->vec[2]) > 0.0001) &&
(len_v3v3(bezt->vec[0], bezt->vec[2]) > 0.0002) &&
(len_v3v3(bezt->vec[0], bezt->vec[2]) > MAX2(len_v3v3(bezt->vec[0], bezt->vec[1]), len_v3v3(bezt->vec[1], bezt->vec[2]))) &&
bezt->h1 != HD_VECT && bezt->h2 != HD_VECT)
{
bezt->h1= bezt->h2= HD_ALIGN;

@ -30,7 +30,7 @@
#include "BLI_graph.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_utildefines.h"
@ -267,7 +267,7 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit)
{
for(node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next)
{
if (node_replaced != node_src && VecLenf(node_replaced->p, node_src->p) <= limit)
if (node_replaced != node_src && len_v3v3(node_replaced->p, node_src->p) <= limit)
{
BLI_replaceNode(graph, node_src, node_replaced);
}
@ -283,7 +283,7 @@ BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit)
for(node = graph->nodes.first; node; node = node->next)
{
float distance = VecLenf(p, node->p);
float distance = len_v3v3(p, node->p);
if (distance <= limit && (closest_node == NULL || distance < min_distance))
{
closest_node = node;
@ -526,10 +526,10 @@ void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3])
{
float dv[3], pv[3];
VecSubf(dv, v, center);
Projf(pv, dv, axis);
VecMulf(pv, -2);
VecAddf(v, v, pv);
sub_v3_v3v3(dv, v, center);
project_v3_v3v3(pv, dv, axis);
mul_v3_fl(pv, -2);
add_v3_v3v3(v, v, pv);
}
static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, int total, float axis[3], float limit, int group)
@ -546,7 +546,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring,
for (j = i + 1; j < total; j++)
{
float angle = Inpf(ring[i].n, ring[j].n);
float angle = dot_v3v3(ring[i].n, ring[j].n);
/* map negative values to 1..2 */
if (angle < 0)
@ -579,8 +579,8 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring,
float p[3];
int j = (i + 1) % total; /* next arc in the circular list */
VecAddf(tangent, ring[i].n, ring[j].n);
Crossf(normal, tangent, axis);
add_v3_v3v3(tangent, ring[i].n, ring[j].n);
cross_v3_v3v3(normal, tangent, axis);
node1 = BLI_otherNode(ring[i].arc, root_node);
node2 = BLI_otherNode(ring[j].arc, root_node);
@ -589,7 +589,7 @@ static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring,
BLI_mirrorAlongAxis(p, root_node->p, normal);
/* check if it's within limit before continuing */
if (VecLenf(node1->p, p) > limit)
if (len_v3v3(node1->p, p) > limit)
{
symmetric = 0;
}
@ -658,11 +658,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo
unit->arc = connectedArc;
/* project the node to node vector on the symmetry plane */
VecSubf(unit->n, otherNode->p, root_node->p);
Projf(vec, unit->n, axis);
VecSubf(unit->n, unit->n, vec);
sub_v3_v3v3(unit->n, otherNode->p, root_node->p);
project_v3_v3v3(vec, unit->n, axis);
sub_v3_v3v3(unit->n, unit->n, vec);
Normalize(unit->n);
normalize_v3(unit->n);
unit++;
}
@ -780,9 +780,9 @@ static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int
arc->symmetry_group = group;
VecSubf(vec, end_node->p, root_node->p);
sub_v3_v3v3(vec, end_node->p, root_node->p);
if (Inpf(vec, root_node->symmetry_axis) < 0)
if (dot_v3v3(vec, root_node->symmetry_axis) < 0)
{
arc->symmetry_flag |= SYM_SIDE_NEGATIVE;
}
@ -796,26 +796,26 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
{
float nor[3], vec[3], p[3];
VecSubf(p, node1->p, root_node->p);
Crossf(nor, p, axis);
sub_v3_v3v3(p, node1->p, root_node->p);
cross_v3_v3v3(nor, p, axis);
VecSubf(p, root_node->p, node2->p);
Crossf(vec, p, axis);
VecAddf(vec, vec, nor);
sub_v3_v3v3(p, root_node->p, node2->p);
cross_v3_v3v3(vec, p, axis);
add_v3_v3v3(vec, vec, nor);
Crossf(nor, vec, axis);
cross_v3_v3v3(nor, vec, axis);
if (abs(nor[0]) > abs(nor[1]) && abs(nor[0]) > abs(nor[2]) && nor[0] < 0)
{
VecNegf(nor);
negate_v3(nor);
}
else if (abs(nor[1]) > abs(nor[0]) && abs(nor[1]) > abs(nor[2]) && nor[1] < 0)
{
VecNegf(nor);
negate_v3(nor);
}
else if (abs(nor[2]) > abs(nor[1]) && abs(nor[2]) > abs(nor[0]) && nor[2] < 0)
{
VecNegf(nor);
negate_v3(nor);
}
/* mirror node2 along axis */
@ -823,7 +823,7 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
BLI_mirrorAlongAxis(p, root_node->p, nor);
/* check if it's within limit before continuing */
if (VecLenf(node1->p, p) <= limit)
if (len_v3v3(node1->p, p) <= limit)
{
/* mark node as symmetric physically */
VECCOPY(root_node->symmetry_axis, nor);
@ -905,12 +905,12 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int
/* If arc is on the axis */
else if (connectedArc->symmetry_level == level)
{
VecAddf(axis, axis, connectedArc->head->p);
VecSubf(axis, axis, connectedArc->tail->p);
add_v3_v3v3(axis, axis, connectedArc->head->p);
sub_v3_v3v3(axis, axis, connectedArc->tail->p);
}
}
Normalize(axis);
normalize_v3(axis);
/* Split between axial and radial symmetry */
if (count == 2)

@ -34,7 +34,7 @@
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_jitter.h"

@ -254,5 +254,26 @@ MINLINE float normalize_v3(float n[3])
return d;
}
MINLINE double normalize_dv3(double n[3])
{
double d= n[0]*n[0] + n[1]*n[1] + n[2]*n[2];
/* a larger value causes normalize errors in a
scaled down models with camera xtreme close */
if(d > 1.0e-35f) {
d= 1.0 / sqrt(d);
n[0] *= d;
n[1] *= d;
n[2] *= d;
}
else {
n[0] = n[1] = n[2] = 0.0;
d= 0.0;
}
return d;
}
#endif /* BLI_MATH_VECTOR_INLINE */

@ -41,7 +41,7 @@
#include "DNA_listBase.h"
#include "DNA_mesh_types.h"
#include "BLI_editVert.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_scanfill.h"
#include "BLI_callbacks.h"
@ -445,13 +445,13 @@ static void testvertexnearedge(void)
eed= filledgebase.first;
while(eed) {
if(eve!=eed->v1 && eve!=eed->v2 && eve->xs==eed->f1) {
if(FloatCompare(eve->co,eed->v1->co, COMPLIMIT)) {
if(compare_v3v3(eve->co,eed->v1->co, COMPLIMIT)) {
ed1->v2= eed->v1;
eed->v1->h++;
eve->h= 0;
break;
}
else if(FloatCompare(eve->co,eed->v2->co, COMPLIMIT)) {
else if(compare_v3v3(eve->co,eed->v2->co, COMPLIMIT)) {
ed1->v2= eed->v2;
eed->v2->h++;
eve->h= 0;
@ -463,7 +463,7 @@ static void testvertexnearedge(void)
vec2[0]= eed->v2->co[cox];
vec2[1]= eed->v2->co[coy];
if(boundinsideEV(eed,eve)) {
dist= DistVL2Dfl(vec1,vec2,vec3);
dist= dist_to_line_v2(vec1,vec2,vec3);
if(dist<COMPLIMIT) {
/* new edge */
ed1= BLI_addfilledge(eed->v1, eve);
@ -813,8 +813,8 @@ int BLI_edgefill(int mode, int mat_nr)
if (mode & 2) {
/*use shortest diagonal for quad*/
VecSubf(vec1, eve->co, eve->next->next->co);
VecSubf(vec2, eve->next->co, eve->next->next->next->co);
sub_v3_v3v3(vec1, eve->co, eve->next->next->co);
sub_v3_v3v3(vec2, eve->next->co, eve->next->next->next->co);
if (INPR(vec1, vec1) < INPR(vec2, vec2)) {
addfillface(eve, eve->next, eve->next->next, 0);
@ -864,12 +864,12 @@ int BLI_edgefill(int mode, int mat_nr)
eve= fillvertbase.first;
while(eve) {
if(v2) {
if( FloatCompare(v2, eve->co, COMPLIMIT)==0) {
len= CalcNormFloat(v1, v2, eve->co, norm);
if( compare_v3v3(v2, eve->co, COMPLIMIT)==0) {
len= normal_tri_v3( norm,v1, v2, eve->co);
if(len != 0.0) break;
}
}
else if(FloatCompare(v1, eve->co, COMPLIMIT)==0) {
else if(compare_v3v3(v1, eve->co, COMPLIMIT)==0) {
v2= eve->co;
}
eve= eve->next;

@ -102,7 +102,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_storage_types.h" // for relname flags
#include "BLI_cellalloc.h"
@ -8642,7 +8642,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
/* correctly initialise constinv matrix */
Mat4One(ob->constinv);
unit_m4(ob->constinv);
if (ob->type == OB_ARMATURE) {
if (ob->pose) {
@ -8672,7 +8672,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
/* correctly initialise constinv matrix */
Mat4One(pchan->constinv);
unit_m4(pchan->constinv);
}
}
}
@ -10077,7 +10077,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* Add default gravity to scenes */
for(sce= main->scene.first; sce; sce= sce->id.next) {
if((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0
&& VecLength(sce->physics_settings.gravity) == 0.0f) {
&& len_v3(sce->physics_settings.gravity) == 0.0f) {
sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
sce->physics_settings.gravity[2] = -9.81f;

@ -56,7 +56,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
#include "DNA_key_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_rand.h"
#include "BLI_ghash.h"
@ -165,7 +165,7 @@ void convert_to_triface(int direction)
if(efa->v4) {
if(efa->f & SELECT) {
/* choose shortest diagonal for split */
fac= VecLenf(efa->v1->co, efa->v3->co) - VecLenf(efa->v2->co, efa->v4->co);
fac= len_v3v3(efa->v1->co, efa->v3->co) - len_v3v3(efa->v2->co, efa->v4->co);
/* this makes sure exact squares get split different in both cases */
if( (direction==0 && fac<FLT_EPSILON) || (direction && fac>0.0f) ) {
efan= EM_face_from_faces(efa, NULL, 0, 1, 2, -1);
@ -691,8 +691,8 @@ void extrude_mesh(void)
else {
initTransform(TFM_TRANSLATION, CTX_NO_PET|CTX_NO_MIRROR);
if(transmode=='n') {
Mat4MulVecfl(G.obedit->obmat, nor);
VecSubf(nor, nor, G.obedit->obmat[3]);
mul_m4_v3(G.obedit->obmat, nor);
sub_v3_v3v3(nor, nor, G.obedit->obmat[3]);
BIF_setSingleAxisConstraint(nor, "along normal");
}
Transform();
@ -744,15 +744,15 @@ void extrude_repeat_mesh(int steps, float offs)
dvec[0]= G.vd->persinv[2][0];
dvec[1]= G.vd->persinv[2][1];
dvec[2]= G.vd->persinv[2][2];
Normalize(dvec);
normalize_v3(dvec);
dvec[0]*= offs;
dvec[1]*= offs;
dvec[2]*= offs;
/* base correction */
Mat3CpyMat4(bmat, G.obedit->obmat);
Mat3Inv(tmat, bmat);
Mat3MulVecfl(tmat, dvec);
copy_m3_m4(bmat, G.obedit->obmat);
invert_m3_m3(tmat, bmat);
mul_m3_v3(tmat, dvec);
for(a=0; a<steps; a++) {
extrudeflag(SELECT, nor);
@ -784,15 +784,15 @@ void spin_mesh(int steps, float degr, float *dvec, int mode)
if(multires_test()) return;
/* imat and center and size */
Mat3CpyMat4(bmat, G.obedit->obmat);
Mat3Inv(imat,bmat);
copy_m3_m4(bmat, G.obedit->obmat);
invert_m3_m3(imat,bmat);
curs= give_cursor();
VECCOPY(cent, curs);
cent[0]-= G.obedit->obmat[3][0];
cent[1]-= G.obedit->obmat[3][1];
cent[2]-= G.obedit->obmat[3][2];
Mat3MulVecfl(imat, cent);
mul_m3_v3(imat, cent);
phi= degr*M_PI/360.0;
phi/= steps;
@ -807,17 +807,17 @@ void spin_mesh(int steps, float degr, float *dvec, int mode)
n[1]= G.vd->viewinv[2][1];
n[2]= G.vd->viewinv[2][2];
}
Normalize(n);
normalize_v3(n);
q[0]= (float)cos(phi);
si= (float)sin(phi);
q[1]= n[0]*si;
q[2]= n[1]*si;
q[3]= n[2]*si;
QuatToMat3(q, cmat);
quat_to_mat3( cmat,q);
Mat3MulMat3(tmat,cmat,bmat);
Mat3MulMat3(bmat,imat,tmat);
mul_m3_m3m3(tmat,cmat,bmat);
mul_m3_m3m3(bmat,imat,tmat);
if(mode==0) if(G.scene->toolsettings->editbutflag & B_KEEPORIG) adduplicateflag(1);
ok= 1;
@ -831,7 +831,7 @@ void spin_mesh(int steps, float degr, float *dvec, int mode)
}
rotateflag(SELECT, cent, bmat);
if(dvec) {
Mat3MulVecfl(bmat,dvec);
mul_m3_v3(bmat,dvec);
translateflag(SELECT, dvec);
}
}
@ -1229,8 +1229,8 @@ static void alter_co(float *co, EditEdge *edge, float rad, int beauty, float per
/* we calculate an offset vector vec1[], to be added to *co */
float len, fac, nor[3], nor1[3], nor2[3];
VecSubf(nor, edge->v1->co, edge->v2->co);
len= 0.5f*Normalize(nor);
sub_v3_v3v3(nor, edge->v1->co, edge->v2->co);
len= 0.5f*normalize_v3(nor);
VECCOPY(nor1, edge->v1->no);
VECCOPY(nor2, edge->v2->no);
@ -1259,17 +1259,17 @@ static void alter_co(float *co, EditEdge *edge, float rad, int beauty, float per
}
else {
if(rad > 0.0) { /* subdivide sphere */
Normalize(co);
normalize_v3(co);
co[0]*= rad;
co[1]*= rad;
co[2]*= rad;
}
else if(rad< 0.0) { /* fractal subdivide */
fac= rad* VecLenf(edge->v1->co, edge->v2->co);
fac= rad* len_v3v3(edge->v1->co, edge->v2->co);
vec1[0]= fac*(float)(0.5-BLI_drand());
vec1[1]= fac*(float)(0.5-BLI_drand());
vec1[2]= fac*(float)(0.5-BLI_drand());
VecAddf(co, co, vec1);
add_v3_v3v3(co, co, vec1);
}
}
@ -1312,7 +1312,7 @@ static EditVert *subdivide_edge_addvert(EditEdge *edge, float rad, int beauty, f
ev->no[0] = (edge->v2->no[0]-edge->v1->no[0])*percent + edge->v1->no[0];
ev->no[1] = (edge->v2->no[1]-edge->v1->no[1])*percent + edge->v1->no[1];
ev->no[2] = (edge->v2->no[2]-edge->v1->no[2])*percent + edge->v1->no[2];
Normalize(ev->no);
normalize_v3(ev->no);
return ev;
}
@ -1342,11 +1342,11 @@ static void facecopy(EditFace *source, EditFace *target)
target->flag = source->flag;
target->h = source->h;
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v1->co, w[0]);
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v2->co, w[1]);
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v3->co, w[2]);
interp_weights_face_v3( w[0],v1, v2, v3, v4, target->v1->co);
interp_weights_face_v3( w[1],v1, v2, v3, v4, target->v2->co);
interp_weights_face_v3( w[2],v1, v2, v3, v4, target->v3->co);
if (target->v4)
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v4->co, w[3]);
interp_weights_face_v3( w[3],v1, v2, v3, v4, target->v4->co);
CustomData_em_interp(&em->fdata, &source->data, NULL, (float*)w, 1, target->data);
}
@ -2527,15 +2527,15 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
VECCOPY(v2mat, ef->v2->co);
VECCOPY(v3mat, ef->v3->co);
VECCOPY(v4mat, ef->v4->co);
Mat4Mul3Vecfl(G.obedit->obmat, v1mat);
Mat4Mul3Vecfl(G.obedit->obmat, v2mat);
Mat4Mul3Vecfl(G.obedit->obmat, v3mat);
Mat4Mul3Vecfl(G.obedit->obmat, v4mat);
mul_mat3_m4_v3(G.obedit->obmat, v1mat);
mul_mat3_m4_v3(G.obedit->obmat, v2mat);
mul_mat3_m4_v3(G.obedit->obmat, v3mat);
mul_mat3_m4_v3(G.obedit->obmat, v4mat);
length[0] = VecLenf(v1mat, v2mat);
length[1] = VecLenf(v2mat, v3mat);
length[2] = VecLenf(v3mat, v4mat);
length[3] = VecLenf(v4mat, v1mat);
length[0] = len_v3v3(v1mat, v2mat);
length[1] = len_v3v3(v2mat, v3mat);
length[2] = len_v3v3(v3mat, v4mat);
length[3] = len_v3v3(v4mat, v1mat);
sort[0] = ef->e1;
sort[1] = ef->e2;
sort[2] = ef->e3;
@ -3101,20 +3101,20 @@ void beauty_fill(void)
* the area divided by the total edge lengths
*/
len1= VecLenf(v1->co, v2->co);
len2= VecLenf(v2->co, v3->co);
len3= VecLenf(v3->co, v4->co);
len4= VecLenf(v4->co, v1->co);
len5= VecLenf(v1->co, v3->co);
len6= VecLenf(v2->co, v4->co);
len1= len_v3v3(v1->co, v2->co);
len2= len_v3v3(v2->co, v3->co);
len3= len_v3v3(v3->co, v4->co);
len4= len_v3v3(v4->co, v1->co);
len5= len_v3v3(v1->co, v3->co);
len6= len_v3v3(v2->co, v4->co);
opp1= AreaT3Dfl(v1->co, v2->co, v3->co);
opp2= AreaT3Dfl(v1->co, v3->co, v4->co);
opp1= area_tri_v3(v1->co, v2->co, v3->co);
opp2= area_tri_v3(v1->co, v3->co, v4->co);
fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5);
opp1= AreaT3Dfl(v2->co, v3->co, v4->co);
opp2= AreaT3Dfl(v2->co, v4->co, v1->co);
opp1= area_tri_v3(v2->co, v3->co, v4->co);
opp2= area_tri_v3(v2->co, v4->co, v1->co);
fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6);
@ -3199,43 +3199,43 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert
minarea, maxarea, areaA, areaB;
/*First Test: Normal difference*/
CalcNormFloat(v1->co, v2->co, v3->co, noA1);
CalcNormFloat(v1->co, v3->co, v4->co, noA2);
normal_tri_v3( noA1,v1->co, v2->co, v3->co);
normal_tri_v3( noA2,v1->co, v3->co, v4->co);
if(noA1[0] == noA2[0] && noA1[1] == noA2[1] && noA1[2] == noA2[2]) normalADiff = 0.0;
else normalADiff = VecAngle2(noA1, noA2);
else normalADiff = angle_v2v2(noA1, noA2);
//if(!normalADiff) normalADiff = 179;
CalcNormFloat(v2->co, v3->co, v4->co, noB1);
CalcNormFloat(v4->co, v1->co, v2->co, noB2);
normal_tri_v3( noB1,v2->co, v3->co, v4->co);
normal_tri_v3( noB2,v4->co, v1->co, v2->co);
if(noB1[0] == noB2[0] && noB1[1] == noB2[1] && noB1[2] == noB2[2]) normalBDiff = 0.0;
else normalBDiff = VecAngle2(noB1, noB2);
else normalBDiff = angle_v2v2(noB1, noB2);
//if(!normalBDiff) normalBDiff = 179;
measure += (normalADiff/360) + (normalBDiff/360);
if(measure > limit) return measure;
/*Second test: Colinearity*/
VecSubf(edgeVec1, v1->co, v2->co);
VecSubf(edgeVec2, v2->co, v3->co);
VecSubf(edgeVec3, v3->co, v4->co);
VecSubf(edgeVec4, v4->co, v1->co);
sub_v3_v3v3(edgeVec1, v1->co, v2->co);
sub_v3_v3v3(edgeVec2, v2->co, v3->co);
sub_v3_v3v3(edgeVec3, v3->co, v4->co);
sub_v3_v3v3(edgeVec4, v4->co, v1->co);
diff = 0.0;
diff = (
fabs(VecAngle2(edgeVec1, edgeVec2) - 90) +
fabs(VecAngle2(edgeVec2, edgeVec3) - 90) +
fabs(VecAngle2(edgeVec3, edgeVec4) - 90) +
fabs(VecAngle2(edgeVec4, edgeVec1) - 90)) / 360;
fabs(angle_v2v2(edgeVec1, edgeVec2) - 90) +
fabs(angle_v2v2(edgeVec2, edgeVec3) - 90) +
fabs(angle_v2v2(edgeVec3, edgeVec4) - 90) +
fabs(angle_v2v2(edgeVec4, edgeVec1) - 90)) / 360;
if(!diff) return 0.0;
measure += diff;
if(measure > limit) return measure;
/*Third test: Concavity*/
areaA = AreaT3Dfl(v1->co, v2->co, v3->co) + AreaT3Dfl(v1->co, v3->co, v4->co);
areaB = AreaT3Dfl(v2->co, v3->co, v4->co) + AreaT3Dfl(v4->co, v1->co, v2->co);
areaA = area_tri_v3(v1->co, v2->co, v3->co) + area_tri_v3(v1->co, v3->co, v4->co);
areaB = area_tri_v3(v2->co, v3->co, v4->co) + area_tri_v3(v4->co, v1->co, v2->co);
if(areaA <= areaB) minarea = areaA;
else minarea = areaB;
@ -3654,7 +3654,7 @@ static void edge_rotate(EditEdge *eed,int dir)
return;
/* coplaner faces only please */
if(Inpf(face[0]->n,face[1]->n) <= 0.000001)
if(dot_v3v3(face[0]->n,face[1]->n) <= 0.000001)
return;
/* we want to construct an array of vertex indicis in both faces, starting at
@ -3852,17 +3852,17 @@ static void bevel_displace_vec(float *midvec, float *v1, float *v2, float *v3, f
{
float a[3], c[3], n_a[3], n_c[3], mid[3], ac, ac2, fac;
VecSubf(a, v1, v2);
VecSubf(c, v3, v2);
sub_v3_v3v3(a, v1, v2);
sub_v3_v3v3(c, v3, v2);
Crossf(n_a, a, no);
Normalize(n_a);
Crossf(n_c, no, c);
Normalize(n_c);
cross_v3_v3v3(n_a, a, no);
normalize_v3(n_a);
cross_v3_v3v3(n_c, no, c);
normalize_v3(n_c);
Normalize(a);
Normalize(c);
ac = Inpf(a, c);
normalize_v3(a);
normalize_v3(c);
ac = dot_v3v3(a, c);
if (ac == 1 || ac == -1) {
midvec[0] = midvec[1] = midvec[2] = 0;
@ -3870,11 +3870,11 @@ static void bevel_displace_vec(float *midvec, float *v1, float *v2, float *v3, f
}
ac2 = ac * ac;
fac = (float)sqrt((ac2 + 2*ac + 1)/(1 - ac2) + 1);
VecAddf(mid, n_c, n_a);
Normalize(mid);
VecMulf(mid, d * fac);
VecAddf(mid, mid, v2);
VecCopyf(midvec, mid);
add_v3_v3v3(mid, n_c, n_a);
normalize_v3(mid);
mul_v3_fl(mid, d * fac);
add_v3_v3v3(mid, mid, v2);
copy_v3_v3(midvec, mid);
}
/* Finds the new point using the sinus law to extrapolate a triangle
@ -3885,32 +3885,32 @@ static void fix_bevel_wrap(float *midvec, float *v1, float *v2, float *v3, float
{
float a[3], b[3], c[3], l_a, l_b, l_c, s_a, s_b, s_c, Pos1[3], Pos2[3], Dir[3];
VecSubf(a, v3, v2);
l_a = Normalize(a);
VecSubf(b, v4, v3);
Normalize(b);
VecSubf(c, v1, v2);
Normalize(c);
sub_v3_v3v3(a, v3, v2);
l_a = normalize_v3(a);
sub_v3_v3v3(b, v4, v3);
normalize_v3(b);
sub_v3_v3v3(c, v1, v2);
normalize_v3(c);
s_b = Inpf(a, c);
s_b = dot_v3v3(a, c);
s_b = (float)sqrt(1 - (s_b * s_b));
s_a = Inpf(b, c);
s_a = dot_v3v3(b, c);
s_a = (float)sqrt(1 - (s_a * s_a));
VecMulf(a, -1);
s_c = Inpf(a, b);
mul_v3_fl(a, -1);
s_c = dot_v3v3(a, b);
s_c = (float)sqrt(1 - (s_c * s_c));
l_b = s_b * l_a / s_a;
l_c = s_c * l_a / s_a;
VecMulf(b, l_b);
VecMulf(c, l_c);
mul_v3_fl(b, l_b);
mul_v3_fl(c, l_c);
VecAddf(Pos1, v2, c);
VecAddf(Pos2, v3, b);
add_v3_v3v3(Pos1, v2, c);
add_v3_v3v3(Pos2, v3, b);
VecAddf(Dir, Pos1, Pos2);
VecMulf(Dir, 0.5);
add_v3_v3v3(Dir, Pos1, Pos2);
mul_v3_fl(Dir, 0.5);
bevel_displace_vec(midvec, v3, Dir, v2, d, no);
@ -3921,13 +3921,13 @@ static char detect_wrap(float *o_v1, float *o_v2, float *v1, float *v2, float *n
{
float o_a[3], a[3], o_c[3], c[3];
VecSubf(o_a, o_v1, o_v2);
VecSubf(a, v1, v2);
sub_v3_v3v3(o_a, o_v1, o_v2);
sub_v3_v3v3(a, v1, v2);
Crossf(o_c, o_a, no);
Crossf(c, a, no);
cross_v3_v3v3(o_c, o_a, no);
cross_v3_v3v3(c, a, no);
if (Inpf(c, o_c) <= 0)
if (dot_v3v3(c, o_c) <= 0)
return 1;
else
return 0;
@ -3972,32 +3972,32 @@ static void fix_bevel_quad_wrap(float *o_v1, float *o_v2, float *o_v3, float *o_
}
// Edge 2 and 4 inverted
else if (wrap[0] == 0 && wrap[1] == 1 && wrap[2] == 0 && wrap[3] == 1) {
VecAddf(vec, v2, v3);
VecMulf(vec, 0.5);
add_v3_v3v3(vec, v2, v3);
mul_v3_fl(vec, 0.5);
VECCOPY(v2, vec);
VECCOPY(v3, vec);
VecAddf(vec, v1, v4);
VecMulf(vec, 0.5);
add_v3_v3v3(vec, v1, v4);
mul_v3_fl(vec, 0.5);
VECCOPY(v1, vec);
VECCOPY(v4, vec);
}
// Edge 1 and 3 inverted
else if (wrap[0] == 1 && wrap[1] == 0 && wrap[2] == 1 && wrap[3] == 0) {
VecAddf(vec, v1, v2);
VecMulf(vec, 0.5);
add_v3_v3v3(vec, v1, v2);
mul_v3_fl(vec, 0.5);
VECCOPY(v1, vec);
VECCOPY(v2, vec);
VecAddf(vec, v3, v4);
VecMulf(vec, 0.5);
add_v3_v3v3(vec, v3, v4);
mul_v3_fl(vec, 0.5);
VECCOPY(v3, vec);
VECCOPY(v4, vec);
}
// Totally inverted
else if (wrap[0] == 1 && wrap[1] == 1 && wrap[2] == 1 && wrap[3] == 1) {
VecAddf(vec, v1, v2);
VecAddf(vec, vec, v3);
VecAddf(vec, vec, v4);
VecMulf(vec, 0.25);
add_v3_v3v3(vec, v1, v2);
add_v3_v3v3(vec, vec, v3);
add_v3_v3v3(vec, vec, v4);
mul_v3_fl(vec, 0.25);
VECCOPY(v1, vec);
VECCOPY(v2, vec);
VECCOPY(v3, vec);
@ -4013,9 +4013,9 @@ static void fix_bevel_tri_wrap(float *o_v1, float *o_v2, float *o_v3, float *v1,
{
if (detect_wrap(o_v1, o_v2, v1, v2, no)) {
float vec[3];
VecAddf(vec, o_v1, o_v2);
VecAddf(vec, vec, o_v3);
VecMulf(vec, 1.0f/3.0f);
add_v3_v3v3(vec, o_v1, o_v2);
add_v3_v3v3(vec, vec, o_v3);
mul_v3_fl(vec, 1.0f/3.0f);
VECCOPY(v1, vec);
VECCOPY(v2, vec);
VECCOPY(v3, vec);
@ -4276,10 +4276,10 @@ static void bevel_mesh(float bsize, int allfaces)
(eed->v1 != eed2->v2) &&
(eed->v2 != eed2->v1) &&
(eed->v2 != eed2->v2) && (
( VecCompare(eed->v1->co, eed2->v1->co, limit) &&
VecCompare(eed->v2->co, eed2->v2->co, limit) ) ||
( VecCompare(eed->v1->co, eed2->v2->co, limit) &&
VecCompare(eed->v2->co, eed2->v1->co, limit) ) ) )
( compare_v3v3(eed->v1->co, eed2->v1->co, limit) &&
compare_v3v3(eed->v2->co, eed2->v2->co, limit) ) ||
( compare_v3v3(eed->v1->co, eed2->v2->co, limit) &&
compare_v3v3(eed->v2->co, eed2->v1->co, limit) ) ) )
{
#ifdef BEV_DEBUG
@ -4308,7 +4308,7 @@ static void bevel_mesh(float bsize, int allfaces)
if(exist_face(neweve[0], neweve[1], neweve[2], neweve[3])==0) {
efa= NULL;
if (VecCompare(eed->v1->co, eed2->v2->co, limit)) {
if (compare_v3v3(eed->v1->co, eed2->v2->co, limit)) {
efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], example,NULL);
} else {
efa= addfacelist(neweve[0], neweve[2], neweve[3], neweve[1], example,NULL);
@ -4316,7 +4316,7 @@ static void bevel_mesh(float bsize, int allfaces)
if(efa) {
float inp;
CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n);
normal_tri_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co);
inp= efa->n[0]*G.vd->viewmat[0][2] + efa->n[1]*G.vd->viewmat[1][2] + efa->n[2]*G.vd->viewmat[2][2];
if(inp < 0.0) flipface(efa);
#ifdef BEV_DEBUG
@ -4365,7 +4365,7 @@ static void bevel_mesh(float bsize, int allfaces)
eve3= NULL;
while (eve2) {
if ((eve2 != eve) && ((eve2->f & (64|128))==0)) {
if (VecCompare(eve->co, eve2->co, limit)) {
if (compare_v3v3(eve->co, eve2->co, limit)) {
if ((eve->f & (128|64)) == 0) {
/* fprintf(stderr,"Found vertex cluster:\n *\n *\n"); */
eve->f |= 128;
@ -4439,7 +4439,7 @@ static void bevel_mesh(float bsize, int allfaces)
cent[0]= cent[1]= cent[2]= 0.0;
INIT_MINMAX(min, max);
for (b=0; b<a; b++) {
VecAddf(cent, cent, neweve[b]->co);
add_v3_v3v3(cent, cent, neweve[b]->co);
DO_MINMAX(neweve[b]->co, min, max);
}
cent[0]= (min[0]+max[0])/2;
@ -4482,7 +4482,7 @@ static void bevel_mesh(float bsize, int allfaces)
}
if(efa) {
float inp;
CalcNormFloat(neweve[0]->co, neweve[1]->co, neweve[2]->co, efa->n);
normal_tri_v3( efa->n,neweve[0]->co, neweve[1]->co, neweve[2]->co);
inp= efa->n[0]*G.vd->viewmat[0][2] + efa->n[1]*G.vd->viewmat[1][2] + efa->n[2]*G.vd->viewmat[2][2];
if(inp < 0.0) flipface(efa);
#ifdef BEV_DEBUG
@ -4610,7 +4610,7 @@ void bevel_menu_old()
curval[1] = mval[1];
window_to_3d(vec, mval[0]-oval[0], mval[1]-oval[1]);
d = Normalize(vec) / 10;
d = normalize_v3(vec) / 10;
drawd = d * fac;
@ -5219,9 +5219,9 @@ int EdgeSlide(short immediate, float imperc)
}
if(prop == 0) {
len = VecLenf(upVert->co,downVert->co)*((perc+1)/2);
len = len_v3v3(upVert->co,downVert->co)*((perc+1)/2);
if(flip == 1) {
len = VecLenf(upVert->co,downVert->co) - len;
len = len_v3v3(upVert->co,downVert->co) - len;
}
}
@ -5236,7 +5236,7 @@ int EdgeSlide(short immediate, float imperc)
}
else
{
len = MIN2(perc, VecLenf(upVert->co,downVert->co));
len = MIN2(perc, len_v3v3(upVert->co,downVert->co));
len = MAX2(len, 0);
}
}
@ -5254,13 +5254,13 @@ int EdgeSlide(short immediate, float imperc)
tempsv = BLI_ghash_lookup(vertgh,ev);
tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
interp_v3_v3v3(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
if (G.scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
Vec2Lerpf(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc));
interp_v2_v2v2(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc));
fuv_link = suv->fuv_list;
while (fuv_link) {
VECCOPY2D(((float *)fuv_link->link), uv_tmp);
@ -5280,17 +5280,17 @@ int EdgeSlide(short immediate, float imperc)
float newlen;
ev = look->link;
tempsv = BLI_ghash_lookup(vertgh,ev);
newlen = (len / VecLenf(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co));
newlen = (len / len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co));
if(newlen > 1.0) {newlen = 1.0;}
if(newlen < 0.0) {newlen = 0.0;}
if(flip == 0) {
VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
if (G.scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
/* dont do anything if no UVs */
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
Vec2Lerpf(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen));
interp_v2_v2v2(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen));
fuv_link = suv->fuv_list;
while (fuv_link) {
VECCOPY2D(((float *)fuv_link->link), uv_tmp);
@ -5300,14 +5300,14 @@ int EdgeSlide(short immediate, float imperc)
}
}
} else{
VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
if (G.scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
/* dont do anything if no UVs */
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
Vec2Lerpf(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen));
interp_v2_v2v2(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen));
fuv_link = suv->fuv_list;
while (fuv_link) {
VECCOPY2D(((float *)fuv_link->link), uv_tmp);
@ -5630,7 +5630,7 @@ static float mesh_rip_edgedist(float mat[][4], float *co1, float *co2, short *mv
mvalf[0]= (float)mval[0];
mvalf[1]= (float)mval[1];
return PdistVL2Dfl(mvalf, vec1, vec2);
return dist_to_line_segment_v2(mvalf, vec1, vec2);
}
/* helper for below */
@ -5950,7 +5950,7 @@ void shape_copy_from_lerp(KeyBlock* thisBlock, KeyBlock* fromBlock)
for(ev = em->verts.first; ev ; ev = ev->next){
if(ev->f & SELECT){
VecLerpf(ev->co,odata+(ev->keyindex*3),data+(ev->keyindex*3),perc);
interp_v3_v3v3(ev->co,odata+(ev->keyindex*3),data+(ev->keyindex*3),perc);
}
}
sprintf(str,"Blending at %d%c MMB to Copy at 100%c",(int)(perc*100),'%','%');
@ -6714,7 +6714,7 @@ void pathselect(void)
newpe = MEM_mallocN(sizeof(PathEdge), "Path Edge");
newpe->v = ((PathNode*)eed->v2->tmp.p)->u;
if(physical){
newpe->w = VecLenf(eed->v1->co, eed->v2->co);
newpe->w = len_v3v3(eed->v1->co, eed->v2->co);
}
else newpe->w = 1;
newpe->next = 0;
@ -6726,7 +6726,7 @@ void pathselect(void)
newpe = MEM_mallocN(sizeof(PathEdge), "Path Edge");
newpe->v = ((PathNode*)eed->v1->tmp.p)->u;
if(physical){
newpe->w = VecLenf(eed->v1->co, eed->v2->co);
newpe->w = len_v3v3(eed->v1->co, eed->v2->co);
}
else newpe->w = 1;
newpe->next = 0;

@ -2,7 +2,7 @@
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_array.h"
@ -361,11 +361,11 @@ void BM_editselection_center(BMesh *em, float *center, BMEditSelection *ese)
{
if (ese->type==BM_VERT) {
BMVert *eve= ese->data;
VecCopyf(center, eve->co);
copy_v3_v3(center, eve->co);
} else if (ese->type==BM_EDGE) {
BMEdge *eed= ese->data;
VecAddf(center, eed->v1->co, eed->v2->co);
VecMulf(center, 0.5);
add_v3_v3v3(center, eed->v1->co, eed->v2->co);
mul_v3_fl(center, 0.5);
} else if (ese->type==BM_FACE) {
BMFace *efa= ese->data;
BM_Compute_Face_Center(em, efa, center);
@ -376,26 +376,26 @@ void BM_editselection_normal(float *normal, BMEditSelection *ese)
{
if (ese->type==BM_VERT) {
BMVert *eve= ese->data;
VecCopyf(normal, eve->no);
copy_v3_v3(normal, eve->no);
} else if (ese->type==BM_EDGE) {
BMEdge *eed= ese->data;
float plane[3]; /* need a plane to correct the normal */
float vec[3]; /* temp vec storage */
VecAddf(normal, eed->v1->no, eed->v2->no);
VecSubf(plane, eed->v2->co, eed->v1->co);
add_v3_v3v3(normal, eed->v1->no, eed->v2->no);
sub_v3_v3v3(plane, eed->v2->co, eed->v1->co);
/* the 2 vertex normals will be close but not at rightangles to the edge
for rotate about edge we want them to be at right angles, so we need to
do some extra colculation to correct the vert normals,
we need the plane for this */
Crossf(vec, normal, plane);
Crossf(normal, plane, vec);
Normalize(normal);
cross_v3_v3v3(vec, normal, plane);
cross_v3_v3v3(normal, plane, vec);
normalize_v3(normal);
} else if (ese->type==BM_FACE) {
BMFace *efa= ese->data;
VecCopyf(normal, efa->no);
copy_v3_v3(normal, efa->no);
}
}
@ -410,7 +410,7 @@ void BM_editselection_plane(BMesh *em, float *plane, BMEditSelection *ese)
if (ese->prev) { /*use previously selected data to make a usefull vertex plane */
BM_editselection_center(em, vec, ese->prev);
VecSubf(plane, vec, eve->co);
sub_v3_v3v3(plane, vec, eve->co);
} else {
/* make a fake plane thats at rightangles to the normal
we cant make a crossvec from a vec thats the same as the vec
@ -419,7 +419,7 @@ void BM_editselection_plane(BMesh *em, float *plane, BMEditSelection *ese)
if (eve->no[0]<0.5) vec[0]=1;
else if (eve->no[1]<0.5) vec[1]=1;
else vec[2]=1;
Crossf(plane, eve->no, vec);
cross_v3_v3v3(plane, eve->no, vec);
}
} else if (ese->type==BM_EDGE) {
BMEdge *eed= ese->data;
@ -430,9 +430,9 @@ void BM_editselection_plane(BMesh *em, float *plane, BMEditSelection *ese)
(running along the edge).. to flip less often.
at least its more pradictable */
if (eed->v2->co[1] > eed->v1->co[1]) /*check which to do first */
VecSubf(plane, eed->v2->co, eed->v1->co);
sub_v3_v3v3(plane, eed->v2->co, eed->v1->co);
else
VecSubf(plane, eed->v1->co, eed->v2->co);
sub_v3_v3v3(plane, eed->v1->co, eed->v2->co);
} else if (ese->type==BM_FACE) {
BMFace *efa= ese->data;
@ -447,38 +447,38 @@ void BM_editselection_plane(BMesh *em, float *plane, BMEditSelection *ese)
if (efa->no[0]<0.5) vec[0]=1.0f;
else if (efa->no[1]<0.5) vec[1]=1.0f;
else vec[2]=1.0f;
Crossf(plane, efa->no, vec);
cross_v3_v3v3(plane, efa->no, vec);
#if 0 //BMESH_TODO
if (efa->v4) { /*if its a quad- set the plane along the 2 longest edges.*/
float vecA[3], vecB[3];
VecSubf(vecA, efa->v4->co, efa->v3->co);
VecSubf(vecB, efa->v1->co, efa->v2->co);
VecAddf(plane, vecA, vecB);
sub_v3_v3v3(vecA, efa->v4->co, efa->v3->co);
sub_v3_v3v3(vecB, efa->v1->co, efa->v2->co);
add_v3_v3v3(plane, vecA, vecB);
VecSubf(vecA, efa->v1->co, efa->v4->co);
VecSubf(vecB, efa->v2->co, efa->v3->co);
VecAddf(vec, vecA, vecB);
sub_v3_v3v3(vecA, efa->v1->co, efa->v4->co);
sub_v3_v3v3(vecB, efa->v2->co, efa->v3->co);
add_v3_v3v3(vec, vecA, vecB);
/*use the biggest edge length*/
if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2])
VecCopyf(plane, vec);
copy_v3_v3(plane, vec);
} else {
/*start with v1-2 */
VecSubf(plane, efa->v1->co, efa->v2->co);
sub_v3_v3v3(plane, efa->v1->co, efa->v2->co);
/*test the edge between v2-3, use if longer */
VecSubf(vec, efa->v2->co, efa->v3->co);
sub_v3_v3v3(vec, efa->v2->co, efa->v3->co);
if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2])
VecCopyf(plane, vec);
copy_v3_v3(plane, vec);
/*test the edge between v1-3, use if longer */
VecSubf(vec, efa->v3->co, efa->v1->co);
sub_v3_v3v3(vec, efa->v3->co, efa->v1->co);
if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2])
VecCopyf(plane, vec);
copy_v3_v3(plane, vec);
}
#endif
}
Normalize(plane);
normalize_v3(plane);
}
static int BM_check_selection(BMesh *em, void *data)

@ -35,7 +35,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BKE_utildefines.h"
#include "bmesh.h"
@ -232,7 +232,7 @@ void BM_Compute_Normals(BMesh *bm)
continue;
for(l = BMIter_New(&loops, bm, BM_LOOPS_OF_FACE, f ); l; l = BMIter_Step(&loops))
VecAddf(l->v->no, l->v->no, f->no);
add_v3_v3v3(l->v->no, l->v->no, f->no);
}
/*average the vertex normals*/
@ -240,9 +240,9 @@ void BM_Compute_Normals(BMesh *bm)
if (BM_TestHFlag(v, BM_HIDDEN))
continue;
if (Normalize(v->no)==0.0) {
if (normalize_v3(v->no)==0.0) {
VECCOPY(v->no, v->co);
Normalize(v->no);
normalize_v3(v->no);
}
}

@ -6,7 +6,7 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_ghash.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "bmesh.h"

@ -1,6 +1,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_mempool.h"
#include "BLI_blenlib.h"
@ -264,7 +264,7 @@ void BMO_Set_Mat(struct BMOperator *op, char *slotname, float *mat, int size)
if (size == 4) {
memcpy(slot->data.p, mat, sizeof(float)*4*4);
} else if (size == 3) {
Mat4CpyMat3(slot->data.p, mat);
copy_m4_m3(slot->data.p, mat);
} else {
printf("yeek! invalid size in BMO_Set_Mat!\n");
@ -288,7 +288,7 @@ void BMO_Get_Mat3(struct BMOperator *op, char *slotname, float mat[3][3])
if( !(slot->slottype == BMOP_OPSLOT_MAT) )
return;
Mat3CpyMat4(mat, slot->data.p);
copy_m3_m4(mat, slot->data.p);
}
void BMO_Set_Pnt(BMOperator *op, char *slotname, void *p)

@ -4,7 +4,7 @@
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_array.h"
@ -272,7 +272,7 @@ void compute_poly_plane(float (*verts)[3], int nverts)
v1 = verts[i];
v2 = verts[(i+1) % nverts];
v3 = verts[(i+2) % nverts];
CalcNormFloat(v1, v2, v3, norm);
normal_tri_v3( norm,v1, v2, v3);
avgn[0] += norm[0];
avgn[1] += norm[1];
@ -288,7 +288,7 @@ void compute_poly_plane(float (*verts)[3], int nverts)
avgn[0] /= nverts;
avgn[1] /= nverts;
avgn[2] /= nverts;
Normalize(avgn);
normalize_v3(avgn);
}
for(i = 0; i < nverts; i++){
@ -303,7 +303,7 @@ void compute_poly_plane(float (*verts)[3], int nverts)
temp[1] = (avgn[1] * mag);
temp[2] = (avgn[2] * mag);
VecSubf(v1, v1, temp);
sub_v3_v3v3(v1, v1, temp);
}
}
@ -364,7 +364,7 @@ void poly_rotate_plane(float normal[3], float (*verts)[3], int nverts)
double angle;
int i;
Crossf(axis, up, normal);
cross_v3_v3v3(axis, up, normal);
axis[0] *= -1;
axis[1] *= -1;
axis[2] *= -1;
@ -373,11 +373,11 @@ void poly_rotate_plane(float normal[3], float (*verts)[3], int nverts)
if (angle == 0.0f) return;
AxisAngleToQuatd(q, axis, angle);
QuatToMat3(q, mat);
axis_angle_to_quat(q, axis, (float)angle);
quat_to_mat3(mat, q);
for(i = 0; i < nverts; i++)
Mat3MulVecfl(mat, verts[i]);
mul_m3_v3(mat, verts[i]);
}
/*
@ -434,12 +434,12 @@ void BM_Vert_UpdateNormal(BMesh *bm, BMVert *v)
f = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v);
for (; f; f=BMIter_Step(&iter), len++) {
VecAddf(v->no, f->no, v->no);
add_v3_v3v3(v->no, f->no, v->no);
}
if (!len) return;
VecMulf(v->no, 1.0f/(int)len);
mul_v3_fl(v->no, 1.0f/(int)len);
}
void bmesh_update_face_normal(BMesh *bm, BMFace *f, float (*projectverts)[3])
@ -463,7 +463,7 @@ void bmesh_update_face_normal(BMesh *bm, BMFace *f, float (*projectverts)[3])
v1 = f->loopbase->v;
v2 = ((BMLoop*)(f->loopbase->head.next))->v;
v3 = ((BMLoop*)(f->loopbase->head.next->next))->v;
CalcNormFloat(v1->co, v2->co, v3->co, f->no);
normal_tri_v3( f->no,v1->co, v2->co, v3->co);
}
else if(f->len == 4){
BMVert *v1, *v2, *v3, *v4;
@ -471,7 +471,7 @@ void bmesh_update_face_normal(BMesh *bm, BMFace *f, float (*projectverts)[3])
v2 = ((BMLoop*)(f->loopbase->head.next))->v;
v3 = ((BMLoop*)(f->loopbase->head.next->next))->v;
v4 = ((BMLoop*)(f->loopbase->head.prev))->v;
CalcNormFloat4(v1->co, v2->co, v3->co, v4->co, f->no);
normal_quad_v3( f->no,v1->co, v2->co, v3->co, v4->co);
}
else{ /*horrible, two sided face!*/
f->no[0] = 0.0;
@ -649,7 +649,7 @@ static BMLoop *find_ear(BMesh *bm, BMFace *f, float (*verts)[3],
isear = 0;
if(isear) {
/*angle = VecAngle3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]);
/*angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]);
if(!bestear || ABS(angle-45.0f) < bestangle) {
bestear = l;
bestangle = ABS(45.0f-angle);
@ -841,8 +841,8 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
VECCOPY(v2, edgeverts[i*2]);
VECCOPY(v3, edgeverts[i*2+1]);
VecAddf(mid, v2, v3);
VecMulf(mid, 0.5f);
add_v3_v3v3(mid, v2, v3);
mul_v3_fl(mid, 0.5f);
clen = 0;
for (j=0; j<f->len; j++) {

@ -3,7 +3,7 @@
#include "bmesh.h"
#include "bmesh_private.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "BKE_utildefines.h"

@ -6,7 +6,7 @@
#include "BLI_memarena.h"
#include "BLI_blenlib.h"
#include "BLI_array.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "bmesh.h"
#include "bmesh_operators_private.h"

@ -5,7 +5,7 @@
#include "bmesh.h"
#include "mesh_intern.h"
#include "bmesh_private.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include <stdio.h>

@ -7,7 +7,7 @@
#include "BLI_heap.h"
#include "BLI_ghash.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "bmesh.h"
@ -282,8 +282,8 @@ static int convex(float *v1, float *v2, float *v3, float *v4)
float nor[3], nor1[3], nor2[3], vec[4][2];
/* define projection, do both trias apart, quad is undefined! */
CalcNormFloat(v1, v2, v3, nor1);
CalcNormFloat(v1, v3, v4, nor2);
normal_tri_v3( nor1,v1, v2, v3);
normal_tri_v3( nor2,v1, v3, v4);
nor[0]= ABS(nor1[0]) + ABS(nor2[0]);
nor[1]= ABS(nor1[1]) + ABS(nor2[1]);
nor[2]= ABS(nor1[2]) + ABS(nor2[2]);
@ -308,7 +308,7 @@ static int convex(float *v1, float *v2, float *v3, float *v4)
}
/* linetests, the 2 diagonals have to instersect to be convex */
if( IsectLL2Df(vec[0], vec[2], vec[1], vec[3]) > 0 ) return 1;
if( isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0 ) return 1;
return 0;
}
@ -455,7 +455,7 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op)
else v4 = edges2[i]->v1;
}
if (VecLenf(v1->co, v3->co) > VecLenf(v1->co, v4->co)) {
if (len_v3v3(v1->co, v3->co) > len_v3v3(v1->co, v4->co)) {
BMVert *v;
v = v3;
v3 = v4;

@ -5,7 +5,7 @@
#include "bmesh.h"
#include "mesh_intern.h"
#include "bmesh_private.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include <stdio.h>

@ -29,7 +29,7 @@
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_ghash.h"
#include "BLI_array.h"

@ -5,7 +5,7 @@
#include "BLI_ghash.h"
#include "BLI_memarena.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "bmesh.h"

@ -17,7 +17,7 @@
#include "mesh_intern.h"
#include "ED_mesh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_array.h"
@ -53,7 +53,7 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) {
ototedge = bm->totedge;
BMO_Get_Mat4(op, "mat", mtx);
Mat4Invert(imtx, mtx);
invert_m4_m4(imtx, mtx);
BMO_InitOpf(bm, &dupeop, "dupe geom=%s", op, "geom");
BMO_Exec_Op(bm, &dupeop);

@ -7,7 +7,7 @@
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_ghash.h"
#include "BLI_blenlib.h"
#include "BLI_array.h"
@ -539,7 +539,7 @@ void bmesh_finddoubles_exec(BMesh *bm, BMOperator *op)
continue;
}
if (VecLenCompare(v->co, v2->co, dist)) {
if (compare_len_v3v3(v->co, v2->co, dist)) {
BMO_SetFlag(bm, v2, VERT_DOUBLE);
BMO_SetFlag(bm, v, VERT_TARGET);
@ -591,7 +591,7 @@ void bmesh_automerge_exec(BMesh *bm, BMOperator *op)
if (BMO_TestFlag(bm, v2, VERT_IN))
continue;
if (VecLenCompare(v->co, v2->co, dist)) {
if (compare_len_v3v3(v->co, v2->co, dist)) {
BMO_SetFlag(bm, v2, VERT_DOUBLE);
BMO_SetFlag(bm, v, VERT_TARGET);

@ -29,7 +29,7 @@
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_ghash.h"
#include "BLI_array.h"
@ -119,8 +119,8 @@ static void alter_co(float *co, BMEdge *edge, subdparams *params, float perc,
/* we calculate an offset vector vec1[], to be added to *co */
float len, fac, nor[3], nor1[3], nor2[3], smooth=params->smooth;
VecSubf(nor, vsta->co, vend->co);
len= 0.5f*Normalize(nor);
sub_v3_v3v3(nor, vsta->co, vend->co);
len= 0.5f*normalize_v3(nor);
VECCOPY(nor1, vsta->no);
VECCOPY(nor2, vend->no);
@ -151,18 +151,18 @@ static void alter_co(float *co, BMEdge *edge, subdparams *params, float perc,
co[2] += vec1[2];
}
else if(params->beauty & B_SPHERE) { /* subdivide sphere */
Normalize(co);
normalize_v3(co);
co[0]*= params->smooth;
co[1]*= params->smooth;
co[2]*= params->smooth;
}
if(params->beauty & B_FRACTAL) {
fac= params->fractal*VecLenf(vsta->co, vend->co);
fac= params->fractal*len_v3v3(vsta->co, vend->co);
vec1[0]= fac*(float)(0.5-BLI_drand());
vec1[1]= fac*(float)(0.5-BLI_drand());
vec1[2]= fac*(float)(0.5-BLI_drand());
VecAddf(co, co, vec1);
add_v3_v3v3(co, co, vec1);
}
}
@ -761,10 +761,10 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|| e1->v2 == e2->v1 || e1->v2 == e2->v1)) {
float angle;
VecSubf(vec1, e1->v2->co, e1->v1->co);
VecSubf(vec2, e2->v2->co, e2->v1->co);
Normalize(vec1);
Normalize(vec2);
sub_v3_v3v3(vec1, e1->v2->co, e1->v1->co);
sub_v3_v3v3(vec2, e2->v2->co, e2->v1->co);
normalize_v3(vec1);
normalize_v3(vec2);
angle = INPR(vec1, vec2);
angle = ABS(angle);

@ -4,7 +4,7 @@
#include "bmesh.h"
#include "bmesh_private.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include <stdio.h>

@ -17,7 +17,7 @@
#include "mesh_intern.h"
#include "ED_mesh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
@ -53,7 +53,7 @@ void bmesh_transform_exec(BMesh *bm, BMOperator *op)
BMO_Get_Mat4(op, "mat", mat);
BMO_ITER(v, &iter, bm, op, "verts", BM_VERT) {
Mat4MulVecfl(mat, v->co);
mul_m4_v3(mat, v->co);
}
}
@ -63,7 +63,7 @@ void bmesh_translate_exec(BMesh *bm, BMOperator *op)
BMO_Get_Vec(op, "vec", vec);
Mat4One(mat);
unit_m4(mat);
VECCOPY(mat[3], vec);
BMO_CallOpf(bm, "transform mat=%m4 verts=%s", mat, op, "verts");
@ -75,7 +75,7 @@ void bmesh_scale_exec(BMesh *bm, BMOperator *op)
BMO_Get_Vec(op, "vec", vec);
Mat3One(mat);
unit_m3(mat);
mat[0][0] = vec[0];
mat[1][1] = vec[1];
mat[2][2] = vec[2];
@ -92,12 +92,12 @@ void bmesh_rotate_exec(BMesh *bm, BMOperator *op)
/*there has to be a proper matrix way to do this, but
this is how editmesh did it and I'm too tired to think
through the math right now.*/
VecMulf(vec, -1);
mul_v3_fl(vec, -1);
BMO_CallOpf(bm, "translate verts=%s vec=%v", op, "verts", vec);
BMO_CallOpf(bm, "transform mat=%s verts=%s", op, "mat", op, "verts");
VecMulf(vec, -1);
mul_v3_fl(vec, -1);
BMO_CallOpf(bm, "translate verts=%s vec=%v", op, "verts", vec);
}
@ -410,7 +410,7 @@ static void ngon_center(float *v, BMesh *bm, BMFace *f)
v[0] = v[1] = v[2] = 0;
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
VecAddf(v, v, l->v->co);
add_v3_v3v3(v, v, l->v->co);
}
if( f->len )
@ -441,7 +441,7 @@ static float ngon_perimeter(BMesh *bm, BMFace *f)
sv[2] = v[2] = l->v->co[2];
num_verts++;
} else {
perimeter += VecLenf(v, l->v->co);
perimeter += len_v3v3(v, l->v->co);
v[0] = l->v->co[0];
v[1] = l->v->co[1];
v[2] = l->v->co[2];
@ -449,7 +449,7 @@ static float ngon_perimeter(BMesh *bm, BMFace *f)
}
}
perimeter += VecLenf(v, sv);
perimeter += len_v3v3(v, sv);
return perimeter;
}
@ -478,7 +478,7 @@ static float ngon_fake_area(BMesh *bm, BMFace *f)
sv[2] = v[2] = l->v->co[2];
num_verts++;
} else {
area += AreaT3Dfl(v, c, l->v->co);
area += area_tri_v3(v, c, l->v->co);
v[0] = l->v->co[0];
v[1] = l->v->co[1];
v[2] = l->v->co[2];
@ -486,7 +486,7 @@ static float ngon_fake_area(BMesh *bm, BMFace *f)
}
}
area += AreaT3Dfl(v, c, sv);
area += area_tri_v3(v, c, sv);
return area;
}
@ -569,11 +569,11 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
ngon_center(f_ext[i].c, bm, f_ext[i].f);
/* normalize the polygon normal */
VecCopyf(t_no, f_ext[i].f->no);
Normalize(t_no);
copy_v3_v3(t_no, f_ext[i].f->no);
normalize_v3(t_no);
/* compute the plane distance */
f_ext[i].d = Inpf(t_no, f_ext[i].c);
f_ext[i].d = dot_v3v3(t_no, f_ext[i].c);
break;
case SIMFACE_AREA:
@ -614,7 +614,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
break;
case SIMFACE_NORMAL:
angle = RAD2DEG(VecAngle2(fs->no, fm->no)); /* if the angle between the normals -> 0 */
angle = RAD2DEG(angle_v2v2(fs->no, fm->no)); /* if the angle between the normals -> 0 */
if( angle / 180.0 <= thresh ) {
BMO_SetFlag(bm, fm, FACE_MARK);
cont = 0;
@ -622,7 +622,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
break;
case SIMFACE_COPLANAR:
angle = RAD2DEG(VecAngle2(fs->no, fm->no)); /* angle -> 0 */
angle = RAD2DEG(angle_v2v2(fs->no, fm->no)); /* angle -> 0 */
if( angle / 180.0 <= thresh ) { /* and dot product difference -> 0 */
if( fabs(f_ext[i].d - f_ext[indices[idx]].d) <= thresh ) {
BMO_SetFlag(bm, fm, FACE_MARK);
@ -686,7 +686,7 @@ static float edge_angle(BMesh *bm, BMEdge *e)
}
}
angle = VecAngle2(n1, n2);
angle = angle_v2v2(n1, n2);
return angle;
}
@ -754,11 +754,11 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
for( i = 0; i < num_total; i++ ) {
switch( type ) {
case SIMEDGE_LENGTH: /* compute the length of the edge */
e_ext[i].length = VecLenf(e_ext[i].e->v1->co, e_ext[i].e->v2->co);
e_ext[i].length = len_v3v3(e_ext[i].e->v1->co, e_ext[i].e->v2->co);
break;
case SIMEDGE_DIR: /* compute the direction */
VecSubf(e_ext[i].dir, e_ext[i].e->v1->co, e_ext[i].e->v2->co);
sub_v3_v3v3(e_ext[i].dir, e_ext[i].e->v1->co, e_ext[i].e->v2->co);
break;
case SIMEDGE_FACE: /* count the faces around the edge */
@ -791,7 +791,7 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
case SIMEDGE_DIR:
/* compute the angle between the two edges */
angle = RAD2DEG(VecAngle2(e_ext[i].dir, e_ext[indices[idx]].dir));
angle = RAD2DEG(angle_v2v2(e_ext[i].dir, e_ext[indices[idx]].dir));
if( angle > 90.0 ) /* use the smallest angle between the edges */
angle = fabs(angle - 180.0f);
@ -927,7 +927,7 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op)
switch( type ) {
case SIMVERT_NORMAL:
/* compare the angle between the normals */
if( RAD2DEG(VecAngle2(v->no, vs->no) / 180.0 <= thresh )) {
if( RAD2DEG(angle_v2v2(v->no, vs->no) / 180.0 <= thresh )) {
BMO_SetFlag(bm, v, VERT_MARK);
cont = 0;
@ -1268,7 +1268,7 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op)
float e_weight = v_weight;
if( type == VPATH_SELECT_EDGE_LENGTH )
e_weight += VecLenf(e->v1->co, e->v2->co);
e_weight += len_v3v3(e->v1->co, e->v2->co);
else e_weight += 1.0f;
u = ( e->v1 == v ) ? e->v2 : e->v1;

@ -41,7 +41,7 @@
#include "BKE_utildefines.h"
#include "BKE_bmesh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "MTC_matrixops.h"
@ -90,7 +90,7 @@ BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BMesh *bm, BMVert *v
else if (org != NULL) VECCOPY(vtd->org,org);
if (vec != NULL) {
VECCOPY(vtd->vec,vec);
Normalize(vtd->vec);
normalize_v3(vtd->vec);
}
vtd->loc = loc;
@ -144,17 +144,17 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H
/* compare the transform origins to see if we can use the vert co's;
* if they belong to different origins, then we will use the origins to determine
* the vector */
if (VecCompare(vtd1->org,vtd2->org,0.000001f)) {
if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) {
VECSUB(vec,v2->co,v1->co);
if (VecLength(vec) < 0.000001f) {
VecMulf(vec,0);
if (len_v3(vec) < 0.000001f) {
mul_v3_fl(vec,0);
}
return 0;
}
else {
VECSUB(vec,vtd2->org,vtd1->org);
if (VecLength(vec) < 0.000001f) {
VecMulf(vec,0);
if (len_v3(vec) < 0.000001f) {
mul_v3_fl(vec,0);
}
return 1;
}
@ -172,18 +172,18 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H
static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td) {
float factor, vec3[3], tmp[3],c1,c2;
Crossf(tmp,vec1,vec2);
Normalize(tmp);
factor = Inpf(up_vec,tmp);
cross_v3_v3v3(tmp,vec1,vec2);
normalize_v3(tmp);
factor = dot_v3v3(up_vec,tmp);
if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) {
Crossf(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
}
else {
Crossf(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
}
Normalize(vec3);
c1 = Inpf(vec3,vec1);
c2 = Inpf(vec1,vec1);
normalize_v3(vec3);
c1 = dot_v3v3(vec3,vec1);
c2 = dot_v3v3(vec1,vec1);
if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) {
factor = 0.0f;
}
@ -244,8 +244,8 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l,
ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
BME_bevel_get_vec(vec1,v1,v,td);
BME_bevel_get_vec(vec2,v2,v,td);
Crossf(t_up_vec,vec1,vec2);
Normalize(t_up_vec);
cross_v3_v3v3(t_up_vec,vec1,vec2);
normalize_v3(t_up_vec);
up_vec = t_up_vec;
}
else {
@ -295,8 +295,8 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l,
is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */
BME_bevel_get_vec(vec2,v,v2,td); /* get the vector we will be projecting parallel to */
len = VecLength(vec1);
Normalize(vec1);
len = len_v3(vec1);
normalize_v3(vec1);
vtd = BME_get_transdata(td, sv);
vtd1 = BME_get_transdata(td, v);
@ -334,8 +334,8 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l,
}
VECADDFAC(sv->co,v->co,vec1,dis);
VECSUB(vec1,sv->co,vtd1->org);
dis = VecLength(vec1);
Normalize(vec1);
dis = len_v3(vec1);
normalize_v3(vec1);
BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max);
return sv;
@ -354,10 +354,10 @@ static float BME_bevel_set_max(BMVert *v1, BMVert *v2, float value, BME_TransDat
}
else {
VECCOPY(vec2,vtd1->vec);
VecMulf(vec2,vtd1->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec2,vec1);
fac1 = VecLength(vec2)/value;
mul_v3_fl(vec2,vtd1->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec2,vec1);
fac1 = len_v3(vec2)/value;
}
else {
fac1 = 0;
@ -369,10 +369,10 @@ static float BME_bevel_set_max(BMVert *v1, BMVert *v2, float value, BME_TransDat
}
else {
VECCOPY(vec3,vtd2->vec);
VecMulf(vec3,vtd2->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec3,vec1);
fac2 = VecLength(vec2)/value;
mul_v3_fl(vec3,vtd2->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec3,vec1);
fac2 = len_v3(vec2)/value;
}
else {
fac2 = 0;
@ -380,7 +380,7 @@ static float BME_bevel_set_max(BMVert *v1, BMVert *v2, float value, BME_TransDat
}
if (fac1 || fac2) {
max = VecLength(vec1)/(fac1 + fac2);
max = len_v3(vec1)/(fac1 + fac2);
if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
*vtd1->max = max;
}
@ -574,12 +574,12 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM
for (i=0,ol=f->loopbase,l=ol->next; l->next!=ol; l=l->next) {
BME_bevel_get_vec(vec1,l->next->v,ol->v,td);
BME_bevel_get_vec(vec2,l->v,ol->v,td);
Crossf(vec3,vec2,vec1);
cross_v3_v3v3(vec3,vec2,vec1);
VECADD(up_vec,up_vec,vec3);
i++;
}
VecMulf(up_vec,1.0f/i);
Normalize(up_vec);
mul_v3_fl(up_vec,1.0f/i);
normalize_v3(up_vec);
for (i=0,len=f->len; i<len; i++,l=l->next) {
if ((l->e->tflag1 & BME_BEVEL_BEVEL) && (l->e->tflag1 & BME_BEVEL_ORIG)) {
@ -606,10 +606,10 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM
}
else {
VECCOPY(vec2,vtd1->vec);
VecMulf(vec2,vtd1->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec2,vec1);
fac1 = VecLength(vec2)/value;
mul_v3_fl(vec2,vtd1->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec2,vec1);
fac1 = len_v3(vec2)/value;
}
else {
fac1 = 0;
@ -620,17 +620,17 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM
}
else {
VECCOPY(vec3,vtd2->vec);
VecMulf(vec3,vtd2->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec3,vec1);
fac2 = VecLength(vec2)/value;
mul_v3_fl(vec3,vtd2->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec3,vec1);
fac2 = len_v3(vec2)/value;
}
else {
fac2 = 0;
}
}
if (fac1 || fac2) {
max = VecLength(vec1)/(fac1 + fac2);
max = len_v3(vec1)/(fac1 + fac2);
if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
*vtd1->max = max;
}

@ -37,7 +37,7 @@ extern "C"
#include "BKE_image.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_listbase.h"
@ -87,7 +87,7 @@ extern "C"
// This function assumes that quat is normalized.
// The following document was used as reference:
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
void QuatToAxisAngle(float *q, float *axis, float *angle)
void quat_to_axis_angle( float *axis, float *angle,float *q)
{
// quat to axis angle
*angle = 2 * acos(q[0]);
@ -666,11 +666,11 @@ protected:
if (parent_mat) {
float invpar[4][4];
Mat4Invert(invpar, parent_mat);
Mat4MulMat4(local, mat, invpar);
invert_m4_m4(invpar, parent_mat);
mul_m4_m4m4(local, mat, invpar);
}
else {
Mat4CpyMat4(local, mat);
copy_m4_m4(local, mat);
}
TransformBase::decompose(local, loc, rot, size);
@ -681,9 +681,9 @@ protected:
float axis[3];
float angle;
double angle_deg;
EulToQuat(rot, quat);
NormalQuat(quat);
QuatToAxisAngle(quat, axis, &angle);
eul_to_quat( quat,rot);
normalize_qt(quat);
quat_to_axis_angle( axis, &angle,quat);
angle_deg = angle * 180.0f / M_PI;
node.addRotate(axis[0], axis[1], axis[2], angle_deg);
*/
@ -901,12 +901,12 @@ private:
bPoseChannel *parchan = get_pose_channel(ob_arm->pose, bone->parent->name);
float invpar[4][4];
Mat4Invert(invpar, parchan->pose_mat);
Mat4MulMat4(mat, pchan->pose_mat, invpar);
invert_m4_m4(invpar, parchan->pose_mat);
mul_m4_m4m4(mat, pchan->pose_mat, invpar);
}
else {
// get world-space from armature-space
Mat4MulMat4(mat, pchan->pose_mat, ob_arm->obmat);
mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat);
}
TransformWriter::add_node_transform(node, mat, NULL);
@ -1059,9 +1059,9 @@ private:
float inv_bind_mat[4][4];
// make world-space matrix, pose_mat is armature-space
Mat4MulMat4(world, pchan->pose_mat, ob_arm->obmat);
mul_m4_m4m4(world, pchan->pose_mat, ob_arm->obmat);
Mat4Invert(mat, world);
invert_m4_m4(mat, world);
converter.mat4_to_dae(inv_bind_mat, mat);
source.appendValues(inv_bind_mat);
@ -1241,9 +1241,9 @@ public:
if (ob->type == OB_MESH && is_skinned_mesh)
// for skinned mesh we write obmat in <bind_shape_matrix>
Mat4One(mat);
unit_m4(mat);
else
Mat4CpyMat4(mat, ob->obmat);
copy_m4_m4(mat, ob->obmat);
TransformWriter::add_node_transform(node, mat, ob->parent ? ob->parent->obmat : NULL);
@ -2048,7 +2048,7 @@ public:
float eul[3];
QuatToEul(quat, eul);
quat_to_eul( eul,quat);
for (int k = 0; k < 3; k++)
create_bezt(eulcu[k], frame, eul[k]);

@ -50,7 +50,7 @@ extern "C"
#include "BKE_depsgraph.h"
#include "BLI_util.h"
#include "BKE_displist.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
}
#include "BKE_armature.h"
#include "BKE_mesh.h"
@ -62,7 +62,7 @@ extern "C"
#include "BKE_utildefines.h"
#include "BKE_action.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@ -186,7 +186,7 @@ public:
float cur[4][4];
float copy[4][4];
Mat4One(mat);
unit_m4(mat);
for (int i = 0; i < node->getTransformations().getCount(); i++) {
@ -199,7 +199,7 @@ public:
COLLADAFW::Translate *tra = (COLLADAFW::Translate*)tm;
COLLADABU::Math::Vector3& t = tra->getTranslation();
Mat4One(cur);
unit_m4(cur);
cur[3][0] = (float)t[0];
cur[3][1] = (float)t[1];
cur[3][2] = (float)t[2];
@ -214,16 +214,16 @@ public:
float quat[4];
float rot_copy[3][3];
float mat[3][3];
AxisAngleToQuat(quat, axis, angle);
axis_angle_to_quat(quat, axis, angle);
QuatToMat4(quat, cur);
quat_to_mat4( cur,quat);
}
break;
case COLLADAFW::Transformation::SCALE:
{
COLLADABU::Math::Vector3& s = ((COLLADAFW::Scale*)tm)->getScale();
float size[3] = {(float)s[0], (float)s[1], (float)s[2]};
SizeToMat4(size, cur);
size_to_mat4( cur,size);
}
break;
case COLLADAFW::Transformation::MATRIX:
@ -237,8 +237,8 @@ public:
break;
}
Mat4CpyMat4(copy, mat);
Mat4MulMat4(mat, cur, copy);
copy_m4_m4(copy, mat);
mul_m4_m4m4(mat, cur, copy);
if (animation_map) {
// AnimationList that drives this Transformation
@ -346,7 +346,7 @@ private:
ob_arm(skin.ob_arm),
controller_uid(skin.controller_uid)
{
Mat4CpyMat4(bind_shape_matrix, (float (*)[4])skin.bind_shape_matrix);
copy_m4_m4(bind_shape_matrix, (float (*)[4])skin.bind_shape_matrix);
transfer_uint_array_data_const(skin.joints_per_vertex, joints_per_vertex);
transfer_uint_array_data_const(skin.weight_indices, weight_indices);
@ -438,7 +438,7 @@ private:
std::vector<JointData>::iterator it;
for (it = joint_data.begin(); it != joint_data.end(); it++) {
if ((*it).joint_uid == uid) {
Mat4CpyMat4(inv_bind_mat, (*it).inv_bind_mat);
copy_m4_m4(inv_bind_mat, (*it).inv_bind_mat);
return true;
}
}
@ -491,8 +491,8 @@ private:
// we need armature matrix here... where do we get it from I wonder...
// root node/joint? or node with <instance_controller>?
float parmat[4][4];
Mat4One(parmat);
Mat4Invert(ob->parentinv, parmat);
unit_m4(parmat);
invert_m4_m4(ob->parentinv, parmat);
// create all vertex groups
std::vector<JointData>::iterator it;
@ -574,7 +574,7 @@ private:
if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
// get original world-space matrix
Mat4Invert(mat, joint_inv_bind_mat);
invert_m4_m4(mat, joint_inv_bind_mat);
}
// create a bone even if there's no joint data for it (i.e. it has no influence)
else {
@ -585,9 +585,9 @@ private:
// get world-space
if (parent)
Mat4MulMat4(mat, obmat, parent_mat);
mul_m4_m4m4(mat, obmat, parent_mat);
else
Mat4CpyMat4(mat, obmat);
copy_m4_m4(mat, obmat);
}
// TODO rename from Node "name" attrs later
@ -597,21 +597,21 @@ private:
if (parent) bone->parent = parent;
// set head
VecCopyf(bone->head, mat[3]);
copy_v3_v3(bone->head, mat[3]);
// set tail, don't set it to head because 0-length bones are not allowed
float vec[3] = {0.0f, 0.5f, 0.0f};
VecAddf(bone->tail, bone->head, vec);
add_v3_v3v3(bone->tail, bone->head, vec);
// set parent tail
if (parent && totchild == 1) {
VecCopyf(parent->tail, bone->head);
copy_v3_v3(parent->tail, bone->head);
// XXX increase this to prevent "very" small bones?
const float epsilon = 0.000001f;
// derive leaf bone length
float length = VecLenf(parent->head, parent->tail);
float length = len_v3v3(parent->head, parent->tail);
if ((length < leaf_bone_length || totbone == 0) && length > epsilon) {
leaf_bone_length = length;
}
@ -625,20 +625,20 @@ private:
#if 0
// and which row in mat is bone direction
float vec[3];
VecSubf(vec, parent->tail, parent->head);
sub_v3_v3v3(vec, parent->tail, parent->head);
#ifdef COLLADA_DEBUG
printvecf("tail - head", vec);
printmatrix4("matrix", parent_mat);
print_v3("tail - head", vec);
print_m4("matrix", parent_mat);
#endif
for (int i = 0; i < 3; i++) {
#ifdef COLLADA_DEBUG
char *axis_names[] = {"X", "Y", "Z"};
printf("%s-axis length is %f\n", axis_names[i], VecLength(parent_mat[i]));
printf("%s-axis length is %f\n", axis_names[i], len_v3(parent_mat[i]));
#endif
float angle = VecAngle2(vec, parent_mat[i]);
float angle = angle_v2v2(vec, parent_mat[i]);
if (angle < min_angle) {
#ifdef COLLADA_DEBUG
printvecf("picking", parent_mat[i]);
print_v3("picking", parent_mat[i]);
printf("^ %s axis of %s's matrix\n", axis_names[i], get_dae_name(node));
#endif
bone_direction_row = i;
@ -665,7 +665,7 @@ private:
LeafBone leaf;
leaf.bone = bone;
Mat4CpyMat4(leaf.mat, mat);
copy_m4_m4(leaf.mat, mat);
BLI_strncpy(leaf.name, bone->name, sizeof(leaf.name));
leaf_bones.push_back(leaf);
@ -682,10 +682,10 @@ private:
// pointing up
float vec[3] = {0.0f, 0.0f, 1.0f};
VecMulf(vec, leaf_bone_length);
mul_v3_fl(vec, leaf_bone_length);
VecCopyf(leaf.bone->tail, leaf.bone->head);
VecAddf(leaf.bone->tail, leaf.bone->head, vec);
copy_v3_v3(leaf.bone->tail, leaf.bone->head);
add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec);
}
}
@ -2200,7 +2200,7 @@ public:
float quat[4];
EulToQuat(eul, quat);
eul_to_quat( quat,eul);
for (int k = 0; k < 4; k++)
create_bezt(quatcu[k], frame, quat[k]);

@ -39,8 +39,8 @@ public:
void mat4_to_dae(float out[][4], float in[][4])
{
Mat4CpyMat4(out, in);
Mat4Transp(out);
copy_m4_m4(out, in);
transpose_m4(out);
}
void mat4_to_dae_double(double out[][4], float in[][4])
@ -60,9 +60,9 @@ class TransformBase
public:
void decompose(float mat[][4], float *loc, float *rot, float *size)
{
Mat4ToSize(mat, size);
Mat4ToEul(mat, rot);
VecCopyf(loc, mat[3]);
mat4_to_size( size,mat);
mat4_to_eul( rot,mat);
copy_v3_v3(loc, mat[3]);
}
};

@ -37,7 +37,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_listBase.h"
#include "DNA_anim_types.h"

@ -37,7 +37,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_listBase.h"
#include "DNA_anim_types.h"

@ -40,7 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_anim_types.h"
#include "DNA_key_types.h"

@ -36,7 +36,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "DNA_anim_types.h"

@ -47,7 +47,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_rand.h"

@ -41,7 +41,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_dlrbTree.h"
#include "DNA_listBase.h"

@ -32,7 +32,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"

@ -33,7 +33,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"

Some files were not shown because too many files have changed in this diff Show More