int a, tot, cycl=0;
float *ft;
- /* in een pad zitten allemaal punten met gelijke afstand: path->len = aantal pt */
- /* NU MET BEVELCURVE!!! */
+ /* in a path vertices are with equal differences: path->len = number of verts */
+ /* NOW WITH BEVELCURVE!!! */
if(ob==0 || ob->type != OB_CURVE) return;
cu= ob->data;
cu->path=path= MEM_callocN(sizeof(Path), "path");
- /* als POLY: laatste punt != eerste punt */
+ /* if POLY: last vertice != first vertice */
cycl= (bl->poly!= -1);
if(cycl) tot= bl->nr;
/* exception: vector handle paths and polygon paths should be subdivided at least a factor 6 (or more?) */
if(path->len<6*nu->pntsu) path->len= 6*nu->pntsu;
- dist= (float *)MEM_mallocN((tot+1)*4, "berekenpaddist");
+ dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist");
- /* alle lengtes in *dist */
+ /* all lengths in *dist */
bevp= bevpfirst= (BevPoint *)(bl+1);
fp= dist;
*fp= 0;
path->totdist= *fp;
- /* de padpunten in path->data */
- /* nu ook met TILT */
+ /* the path verts in path->data */
+ /* now also with TILT value */
ft= path->data = (float *)MEM_callocN(16*path->len, "pathdata");
bevp= bevpfirst;
d= ((float)a)*fac;
- /* we zoeken plek 'd' in het array */
+ /* we're looking for location (distance) 'd' in the array */
while((d>= *fp) && fp<maxdist) {
fp++;
if(bevp<bevplast) bevp++;
return p1;
}
-int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* geeft OK terug */
+int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK */
{
Curve *cu;
Nurb *nu;
path= cu->path;
fp= path->data;
- /* cyclic testen */
+ /* test for cyclic */
bl= cu->bev.first;
if(bl && bl->poly> -1) cycl= 1;
- /* ctime is van 0.0-1.0 */
+ /* ctime is between 0.0-1.0 */
ctime *= (path->len-1);
s1= (int)floor(ctime);
fac= (float)(s1+1)-ctime;
- /* path->len is gecorrigeerd voor cyclic, zie boven, is beetje warrig! */
+ /* path->len is corected for cyclic */
s0= interval_test(0, path->len-1-cycl, s1-1, cycl);
s1= interval_test(0, path->len-1-cycl, s1, cycl);
s2= interval_test(0, path->len-1-cycl, s1+1, cycl);
dir[1]= data[0]*p0[1] + data[1]*p1[1] + data[2]*p2[1] + data[3]*p3[1] ;
dir[2]= data[0]*p0[2] + data[1]*p1[2] + data[2]*p2[2] + data[3]*p3[2] ;
- /* compatible maken met vectoquat */
+ /* make compatible with vectoquat */
dir[0]= -dir[0];
dir[1]= -dir[1];
dir[2]= -dir[2];
nu= cu->nurb.first;
- /* zeker van zijn dat de eerste en laatste frame door de punten gaat */
+ /* make sure that first and last frame are included in the vectors here */
if((nu->type & 7)==CU_POLY) set_four_ipo(1.0f-fac, data, KEY_LINEAR);
else if((nu->type & 7)==CU_BEZIER) set_four_ipo(1.0f-fac, data, KEY_LINEAR);
else if(s0==s1 || p2==p3) set_four_ipo(1.0f-fac, data, KEY_CARDINAL);
if(ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0;
- /* dit om zeker van te zijn dat er iets gezbufferd wordt: in drawobject.c: dt==wire en boundboxclip */
+ /* this to make sure that something is z-buffered in drawobject.c */
if(G.background==0 && ob->type==OB_MESH) {
Mesh *me= ob->data;
DispList *dl;
newob= MEM_mallocN(sizeof(Object), "newobobj dupli");
memcpy(newob, ob, sizeof(Object));
- /* alleen de basis-ball behoeft een displist */
+ /*only the basis-ball gets a displist */
if(newob->type==OB_MBALL) newob->disp.first= newob->disp.last= 0;
BLI_addtail(&duplilist, newob);
where_is_object(newob);
newob->flag |= OB_FROMDUPLI;
- newob->id.newid= (ID *)ob; /* duplicator bewaren */
+ newob->id.newid= (ID *)ob; /* store duplicator */
}
}
for(a=0; a<totvert; a++, mvert++) {
- /* bereken de extra offset (tov. nulpunt parent) die de kinderen krijgen */
+ /* calc the extra offset for children (wrt. centre parent) */
VECCOPY(vec, mvert->co);
Mat4MulVecfl(pmat, vec);
VecSubf(vec, vec, pmat[3]);
newob= MEM_mallocN(sizeof(Object), "newobj dupli");
memcpy(newob, ob, sizeof(Object));
newob->flag |= OB_FROMDUPLI;
- newob->id.newid= (ID *)par; /* duplicator bewaren */
+ newob->id.newid= (ID *)par; /* keep duplicator */
- /* alleen de basis-ball behoeft een displist */
+ /* only basis-ball gets displist */
if(newob->type==OB_MBALL) newob->disp.first= newob->disp.last= 0;
VECCOPY(newob->obmat[3], vec);
newob= MEM_mallocN(sizeof(Object), "newobj dupli");
memcpy(newob, ob, sizeof(Object));
newob->flag |= OB_FROMDUPLI;
- newob->id.newid= (ID *)par; /* duplicator bewaren */
+ newob->id.newid= (ID *)par; /* keep duplicator */
- /* alleen de basis-ball behoeft een displist */
+ /* only basis-ball gets displist */
if(newob->type==OB_MBALL) newob->disp.first= newob->disp.last= 0;
where_is_particle(paf, pa, ctime, vec);
/* blender.c jan 94 MIXED MODEL
*
- * algemene hulp funkties en data
+ * common help functions and data
*
* $Id$
*
char versionstr[48]= "";
/* ************************************************ */
-/* pushpop faciliteit: om tijdelijk data te bewaren */
+/* pushpop facility: to store data temporally, FIFO! */
ListBase ppmain={0, 0};
-/* ********** vrijgeven ********** */
+/* ********** free ********** */
void free_blender(void)
{
IMB_freeImBufdata(); /* imbuf lib */
}
-void duplicatelist(ListBase *list1, ListBase *list2) /* kopie van 2 naar 1 */
+void duplicatelist(ListBase *list1, ListBase *list2) /* copy from 2 to 1 */
{
struct Link *link1, *link2;
freeAllRad();
free_main(G.main); /* free all lib data */
- freefastshade(); /* anders oude lampgegevens */
+ freefastshade(); /* othwerwise old lamp settings stay active */
- /* hangende vars voorkomen */
+ /* prevent hanging vars */
R.backbuf= 0;
/* force all queues to be left */
G.scene= G.curscreen->scene;
- /* weinig DispListen, wel text_to_curve */
+ /* few DispLists, but do text_to_curve */
// this should be removed!!! But first a better displist system (ton)
for (ob= G.main->object.first; ob; ob= ob->id.next) {
if(ob->type==OB_FONT) {
}
strcpy(G.sce, filename);
- strcpy(G.main->name, filename); /* is gegarandeerd current file */
+ strcpy(G.main->name, filename); /* is guaranteed current file */
MEM_freeN(bfd);
}
-/* curve.c MIXED MODEL
+/* curve.c
*
- * maart 95
*
* $Id$
*
cun->bev.first= cun->bev.last= 0;
cun->path= 0;
- /* ook single user ipo */
+ /* single user ipo too */
if(cun->ipo) cun->ipo= copy_ipo(cun->ipo);
id_us_plus((ID *)cun->vfont);
Curve *cun;
int local=0, lib=0;
- /* - zijn er alleen lib users: niet doen
- * - zijn er alleen locale users: flag zetten
- * - mixed: copy
+ /* - when there are only lib users: don't do
+ * - when there are only local users: set flag
+ * - mixed: do a copy
*/
if(cu->id.lib==0) return;
}
-/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline berekeningen ~~~~~~~~~~~ */
+/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */
-/* voor de goede orde: eigenlijk horen hier doubles gebruikt te worden */
+/* actually, doubles should be used here as much as possible */
void extend_spline(float * pnts, int in, int out)
{
for (k = 3; k > 0; k--){
pnts = _pnts;
- /* punten kopieren naar add */
+ /* copy points to 'add' */
for (i = 0; i < in; i++){
add[i] = *pnts;
pnts += 3;
}
- /* inverse forward differencen */
+ /* inverse forward differencing */
for (i = 0; i < in2; i++){
for (j = in2; j > i; j--){
add[j] -= add[j - 1];
void calcknots(float *knots, short aantal, short order, short type)
-/* knots: aantal pnts NIET gecorrigeerd voor cyclic */
-/* aantal, order, type; 0: uniform, 1: endpoints, 2: bezier */
+/* knots: number of pnts NOT corrected for cyclic */
+/* type; 0: uniform, 1: endpoints, 2: bezier */
{
float k;
int a, t;
}
void makecyclicknots(float *knots, short pnts, short order)
-/* pnts, order: aantal pnts NIET gecorrigeerd voor cyclic */
+/* pnts, order: number of pnts NOT corrected for cyclic */
{
int a, b, order2, c;
if(knots==0) return;
order2=order-1;
- /* eerst lange rijen (order -1) dezelfde knots aan uiteinde verwijderen */
+ /* do first long rows (order -1), remove identical knots at endpoints */
if(order>2) {
b= pnts+order2;
for(a=1; a<order2; a++) {
if(t < knots[0]) t= knots[0];
else if(t > knots[opp2]) t= knots[opp2];
- /* dit stuk is order '1' */
+ /* this part is order '1' */
o2 = order + 1;
for(i=0;i<opp2;i++) {
if(knots[i]!=knots[i+1] && t>= knots[i] && t<=knots[i+1]) {
else basis[i]= 0.0;
}
basis[i]= 0.0;
-
- /* printf("u %f\n", t); for(k=0;k<orderpluspnts;k++) printf(" %2.2f",basis[k]); printf("\n"); */
- /* dit is order 2,3,... */
+ /* this is order 2,3,... */
for(j=2; j<=order; j++) {
if(i2+j>= orderpluspnts) i2= opp2-j;
void makeNurbfaces(Nurb *nu, float *data)
-/* data moet 3*4*resolu*resolv lang zijn en op nul staan */
+/* data has to be 3*4*resolu*resolv in size, and zero-ed */
{
BPoint *bp;
float *basisu, *basis, *basisv, *sum, *fp, *in;
if(nu->orderv>nu->pntsv) return;
if(data==0) return;
- /* alloceren en vars goedzetten */
+ /* allocate and initialize */
len= nu->pntsu*nu->pntsv;
if(len==0) return;
sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbfaces1");
jstart= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces4");
jend= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces5");
- /* voorberekenen basisv en jstart,jend */
+ /* precalculation of basisv and jstart,jend */
if(nu->flagv & 1) cycl= nu->orderv-1;
else cycl= 0;
v= vstart;
jsta= jstart[resolv];
jen= jend[resolv];
- /* bereken sum */
+ /* calculate sum */
sumdiv= 0.0;
fp= sum;
}
}
- /* een! (1.0) echt punt nu */
+ /* one! (1.0) real point now */
fp= sum;
for(j= jsta; j<=jen; j++) {
u+= ustep;
}
- /* vrijgeven */
+ /* free */
MEM_freeN(sum);
MEM_freeN(basisu);
MEM_freeN(basisv);
void makeNurbcurve_forw(Nurb *nu, float *data)
-/* *data: moet 3*4*pntsu*resolu lang zijn en op nul staan */
+/* *data: has to be 3*4*pntsu*resolu in size and zero-ed */
{
BPoint *bp;
float *basisu, *sum, *fp, *in;
if(nu->knotsu==0) return;
if(data==0) return;
- /* alloceren en vars goedzetten */
+ /* allocate and init */
len= nu->pntsu;
if(len==0) return;
sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1");
for (k = nu->orderu - 1; k < nu->pntsu; k++){
wanted = (int)((nu->knotsu[k+1] - nu->knotsu[k]) / ustep);
- org = 4; /* gelijk aan order */
+ org = 4; /* equal to order */
if (org > wanted) org = wanted;
for (j = org; j > 0; j--){
basisNurb(u, nu->orderu, nu->pntsu, nu->knotsu, basisu, &istart, &iend);
- /* bereken sum */
+ /* calc sum */
sumdiv= 0.0;
fp= sum;
for(i= istart; i<=iend; i++, fp++) {
- /* hier nog rationele component doen */
+ /* do the rational component */
*fp= basisu[i];
sumdiv+= *fp;
}
if(sumdiv!=0.0) if(sumdiv<0.999 || sumdiv>1.001) {
- /* is dit normaliseren ook nodig? */
+ /* is this normalizing needed? */
fp= sum;
for(i= istart; i<=iend; i++, fp++) {
*fp/= sumdiv;
}
}
- /* een! (1.0) echt punt nu */
+ /* one! (1.0) real point */
fp= sum;
bp= nu->bp+ istart;
for(i= istart; i<=iend; i++, bp++, fp++) {
}
}
- /* vrijgeven */
+ /* free */
MEM_freeN(sum);
MEM_freeN(basisu);
}
void makeNurbcurve(Nurb *nu, float *data, int dim)
-/* data moet dim*4*pntsu*resolu lang zijn en op nul staan */
+/* data has to be dim*4*pntsu*resolu in size and zero-ed */
{
BPoint *bp;
float u, ustart, uend, ustep, sumdiv;
if(nu->orderu>nu->pntsu) return;
if(data==0) return;
- /* alloceren en vars goedzetten */
+ /* allocate and initialize */
len= nu->pntsu;
if(len==0) return;
sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1");
while(resolu--) {
basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend);
- /* bereken sum */
+ /* calc sum */
sumdiv= 0.0;
fp= sum;
bp= nu->bp+ istart-1;
sumdiv+= *fp;
}
if(sumdiv!=0.0) if(sumdiv<0.999 || sumdiv>1.001) {
- /* is dit normaliseren ook nodig? */
+ /* is normalizing needed? */
fp= sum;
for(i= istart; i<=iend; i++, fp++) {
*fp/= sumdiv;
}
}
- /* een! (1.0) echt punt nu */
+ /* one! (1.0) real point */
fp= sum;
bp= nu->bp+ istart-1;
for(i= istart; i<=iend; i++, fp++) {
u+= ustep;
}
- /* vrijgeven */
+ /* free */
MEM_freeN(sum);
MEM_freeN(basisu);
}
float *data;
- /* eerst voorspellen hoelang datablok moet worden */
+ /* first calculate the size of the datablock */
nu= cu->nurb.first;
while(nu) {
#ifdef STRUBI
#endif
nu= nu->next;
}
- /* makeNurbfaces wil nullen */
+ /* makeNurbfaces wants zeros */
data= cu->orco= MEM_callocN(3*sizeof(float)*tot, "make_orco");
nu= cu->nurb.first;
dl->parts= 1;
dl->nr= nr;
- /* eerst cirkel maken */
+ /* first make circle */
fp= dl->verts;
hoek= -0.5*M_PI;
dhoek= (float)(M_PI/(nr-2));
short bevelinside(BevList *bl1,BevList *bl2)
{
- /* is bl2 INSIDE bl1 ? met links-rechts methode en "labda's" */
- /* geeft als correct gat 1 terug */
+ /* is bl2 INSIDE bl1 ? with left-right method and "labda's" */
+ /* returns '1' if correct hole */
BevPoint *bevp, *prevbevp;
float min,max,vec[3],hvec1[3],hvec2[3],lab,mu;
int nr, links=0,rechts=0,mode;
- /* neem eerste vertex van het mogelijke gat */
+ /* take first vertex of possible hole */
bevp= (BevPoint *)(bl2+1);
hvec1[0]= bevp->x;
VECCOPY(hvec2,hvec1);
hvec2[0]+=1000;
- /* test deze met alle edges van mogelijk omringende poly */
- /* tel aantal overgangen links en rechts */
+ /* test it with all edges of potential surounding poly */
+ /* count number of transitions left-right */
bevp= (BevPoint *)(bl1+1);
nr= bl1->nr;
}
if(min!=max) {
if(min<=hvec1[1] && max>=hvec1[1]) {
- /* er is een overgang, snijpunt berekenen */
+ /* there's a transition, calc intersection point */
mode= cu_isectLL(&(prevbevp->x),&(bevp->x),hvec1,hvec2,0,1,&lab,&mu,vec);
- /* als lab==0.0 of lab==1.0 dan snijdt de edge exact de overgang
- * alleen toestaan voor lab= 1.0 (of andersom, maakt niet uit)
+ /* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition
+ only allow for one situation: we choose lab= 1.0
*/
if(mode>=0 && lab!=0.0) {
if(vec[0]<hvec1[0]) links++;
return 0;
}
-/* deze kan niet zomaar door atan2 vervangen worden, maar waarom? */
+/* this function cannot be replaced with atan2, but why? */
void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *sina, float *cosa)
{
x3= x1-x2;
y3= y1-y2;
if(x3==0 && y3==0) {
- /* printf("x3 en y3 nul \n"); */
x3= y1;
y3= -x1;
} else {
last= nu->bezt+(nu->pntsu-1);
- /* een punt terug */
+ /* returns a point */
if(prevbezt==nu->bezt) {
if(nu->flagu & 1) pprev= last;
else pprev= prevbezt;
}
else pprev= prevbezt-1;
- /* een punt verder */
+ /* next point */
if(bezt==last) {
if(nu->flagu & 1) next= nu->bezt;
else next= bezt;
void makeBevelList(Object *ob)
{
- /* - alle curves omzetten in poly's, met aangegeven resol en vlaggen voor dubbele punten
- - eventueel intelligent punten verwijderen (geval Nurb)
- - scheiden in verschillende blokken met Boundbox
- - Autogat detectie */
+ /*
+ - convert all curves to polys, with indication of resol and flags for double-vertices
+ - possibly; do a smart vertice removal (in case Nurb)
+ - separate in individual blicks with BoundBox
+ - AutoHole detection
+ */
Curve *cu;
Nurb *nu;
BezTriple *bezt, *prevbezt;
struct bevelsort *sortdata, *sd, *sd1;
int a, b, len, nr, poly;
- /* deze fie moet object hebben in verband met tflag en upflag */
+ /* this function needs an object, because of tflag and upflag */
cu= ob->data;
- /* STAP 1: POLY'S MAKEN */
+ /* STEP 1: MAKE POLYS */
BLI_freelistN(&(cu->bev));
if(ob==G.obedit) nu= editNurb.first;
}
else if((nu->type & 7)==CU_BEZIER) {
- len= nu->resolu*(nu->pntsu+ (nu->flagu & 1) -1)+1; /* voor laatste punt niet cyclic */
+ len= nu->resolu*(nu->pntsu+ (nu->flagu & 1) -1)+1; /* in case last point is not cyclic */
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
BLI_addtail(&(cu->bev), bl);
v1= prevbezt->vec[1];
v2= bezt->vec[0];
- /* altijd alle drie doen: anders blijft data hangen */
+ /* always do all three, to prevent data hanging around */
maakbez(v1[0], v1[3], v2[0], v2[3], data, nu->resolu);
maakbez(v1[1], v1[4], v2[1], v2[4], data+1, nu->resolu);
maakbez(v1[2], v1[5], v2[2], v2[5], data+2, nu->resolu);
}
- /* met handlecodes dubbele punten aangeven */
+ /* indicate with handlecodes double points */
if(prevbezt->h1==prevbezt->h2) {
if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= 1;
}
MEM_freeN(data);
MEM_freeN(data_a);
- if((nu->flagu & 1)==0) { /* niet cyclic: endpoint */
+ if((nu->flagu & 1)==0) { /* not cyclic: endpoint */
bevp->x= prevbezt->vec[1][0];
bevp->y= prevbezt->vec[1][1];
bevp->z= prevbezt->vec[1][2];
else bl->poly= -1;
bevp= (BevPoint *)(bl+1);
- data= MEM_callocN(4*sizeof(float)*len, "makeBevelList4"); /* moet op nul staan */
+ data= MEM_callocN(4*sizeof(float)*len, "makeBevelList4"); /* has to be zero-ed */
makeNurbcurve(nu, data, 4);
v1= data;
nu= nu->next;
}
- /* STAP 2: DUBBELE PUNTEN EN AUTOMATISCHE RESOLUTIE, DATABLOKKEN VERKLEINEN */
+ /* STEP 2: DOUBLE POINTS AND AUTOMATIC RESOLUTION, REDUCE DATABLOCKS */
bl= cu->bev.first;
while(bl) {
nr= bl->nr;
while(bl) {
blnext= bl->next;
if(bl->flag) {
- nr= bl->nr- bl->flag+1; /* +1 want vectorbezier zet ook flag */
+ nr= bl->nr- bl->flag+1; /* +1 because vectorbezier sets flag too */
blnew= MEM_mallocN(sizeof(BevList)+nr*sizeof(BevPoint), "makeBevelList");
memcpy(blnew, bl, sizeof(BevList));
blnew->nr= 0;
BLI_remlink(&(cu->bev), bl);
- BLI_insertlinkbefore(&(cu->bev),blnext,blnew); /* zodat bevlijst met nurblijst gelijk loopt */
+ BLI_insertlinkbefore(&(cu->bev),blnext,blnew); /* to make sure bevlijst is tuned with nurblist */
bevp0= (BevPoint *)(bl+1);
bevp1= (BevPoint *)(blnew+1);
nr= bl->nr;
bl= blnext;
}
- /* STAP 3: POLY'S TELLEN EN AUTOGAT */
+ /* STEP 3: COUNT POLYS TELLEN AND AUTOHOLE */
bl= cu->bev.first;
poly= 0;
while(bl) {
if(bl->poly>=0) {
poly++;
bl->poly= poly;
- bl->gat= 0;
+ bl->gat= 0; /* 'gat' is dutch for hole */
}
bl= bl->next;
}
- /* meest linkse punten vinden, tevens richting testen */
+ /* find extreme left points, also test (turning) direction */
if(poly>0) {
sd= sortdata= MEM_mallocN(sizeof(struct bevelsort)*poly, "makeBevelList5");
bl= cu->bev.first;
sd= sortdata+1;
for(a=1; a<poly; a++, sd++) {
- bl= sd->bl; /* is bl een gat? */
+ bl= sd->bl; /* is bl a hole? */
sd1= sortdata+ (a-1);
- for(b=a-1; b>=0; b--, sd1--) { /* alle polys links ervan */
+ for(b=a-1; b>=0; b--, sd1--) { /* all polys to the left */
if(bevelinside(sd1->bl, bl)) {
bl->gat= 1- sd1->bl->gat;
break;
}
}
- /* draairichting */
+ /* turning direction */
if((cu->flag & CU_3D)==0) {
sd= sortdata;
for(a=0; a<poly; a++, sd++) {
MEM_freeN(sortdata);
}
- /* STAP 4: COSINUSSEN */
+ /* STEP 4: COSINES */
bl= cu->bev.first;
while(bl) {
- if(bl->nr==2) { /* 2 pnt, apart afhandelen: KAN DAT NIET AFGESCHAFT? */
+ if(bl->nr==2) { /* 2 pnt, treat separate */
bevp2= (BevPoint *)(bl+1);
bevp1= bevp2+1;
bevp1= bevp2;
bevp2++;
}
- /* niet cyclic gevallen corrigeren */
+ /* correct non-cyclic cases */
if(bl->poly== -1) {
if(bl->nr>2) {
bevp= (BevPoint *)(bl+1);
/*
* handlecodes:
- * 1: niets, 1:auto, 2:vector, 3:aligned
+ * 1: nothing, 1:auto, 2:vector, 3:aligned
*/
len1= VecLenf(p2, p2-3);
if(len1==0.0) len1=1.0;
if(len2==0.0) len2=1.0;
- if(bezt->f1 & 1) { /* volgorde van berekenen */
+ if(bezt->f1 & 1) { /* order of calculation */
if(bezt->h2==HD_ALIGN) { /* aligned */
len= len2/len1;
p2[3]= p2[0]+len*(p2[0]-p2[-3]);
}
}
-void calchandlesNurb(Nurb *nu) /* wel eerst (zonodig) de handlevlaggen zetten */
+void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
{
BezTriple *bezt, *prev, *next;
short a;
void testhandlesNurb(Nurb *nu)
{
- /* Te gebruiken als er iets an de handles is veranderd.
- * Loopt alle BezTriples af met de volgende regels:
- * FASE 1: types veranderen?
- * Autocalchandles: worden ligned als NOT(000 || 111)
- * Vectorhandles worden 'niets' als (selected en andere niet)
- * FASE 2: handles herbereken
- */
+ /* use when something has changed with handles.
+ it treats all BezTriples with the following rules:
+ PHASE 1: do types have to be altered?
+ Auto handles: become aligned when selection status is NOT(000 || 111)
+ Vector handles: become 'nothing' when (one half selected AND other not)
+ PHASE 2: recalculate handles
+ */
BezTriple *bezt;
short flag, a;
void autocalchandlesNurb(Nurb *nu, int flag)
{
- /* Kijkt naar de coordinaten van de handles en berekent de soort */
+ /* checks handle coordinates and calculates type */
BezTriple *bezt2, *bezt1, *bezt0;
int i, align, leftsmall, rightsmall;
align= leftsmall= rightsmall= 0;
- /* linker handle: */
+ /* left handle: */
if(flag==0 || (bezt1->f1 & flag) ) {
bezt1->h1= 0;
- /* afstand te klein: vectorhandle */
+ /* distance too short: vectorhandle */
if( VecLenf( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) {
bezt1->h1= HD_VECT;
leftsmall= 1;
align= 1;
bezt1->h1= HD_ALIGN;
}
- /* of toch vector handle? */
+ /* or vector handle? */
if(DistVL2Dfl(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001)
bezt1->h1= HD_VECT;
}
}
- /* rechter handle: */
+ /* right handle: */
if(flag==0 || (bezt1->f3 & flag) ) {
bezt1->h2= 0;
- /* afstand te klein: vectorhandle */
+ /* distance too short: vectorhandle */
if( VecLenf( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) {
bezt1->h2= HD_VECT;
rightsmall= 1;
/* aligned handle? */
if(align) bezt1->h2= HD_ALIGN;
- /* of toch vector handle? */
+ /* or vector handle? */
if(DistVL2Dfl(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001)
bezt1->h2= HD_VECT;
if(leftsmall && bezt1->h2==HD_ALIGN) bezt1->h2= 0;
if(rightsmall && bezt1->h1==HD_ALIGN) bezt1->h1= 0;
- /* onzalige combinatie: */
+ /* undesired combination: */
if(bezt1->h1==HD_ALIGN && bezt1->h2==HD_VECT) bezt1->h1= 0;
if(bezt1->h2==HD_ALIGN && bezt1->h1==HD_VECT) bezt1->h2= 0;
{
/* code==1: set autohandle */
/* code==2: set vectorhandle */
- /* als code==3 (HD_ALIGN) toggelt het, vectorhandles worden HD_FREE */
+ /* if code==3 (HD_ALIGN) it toggle, vectorhandles become HD_FREE */
Nurb *nu;
BezTriple *bezt;
short a, ok=0;
}
}
else {
- /* is er 1 handle NIET vrij: alles vrijmaken, else ALIGNED maken */
+ /* there is 1 handle not FREE: FREE it all, else make ALIGNED */
nu= editNurb.first;
while(nu) {
a= nu->pntsu;
bezt1= nu->bezt;
bezt2= bezt1+(a-1);
- if(a & 1) a+= 1; /* bij oneven ook van middelste inhoud swappen */
+ if(a & 1) a+= 1; /* if odd, also swap middle content */
a/= 2;
while(a>0) {
if(bezt1!=bezt2) SWAP(BezTriple, *bezt1, *bezt2);
bp2--;
}
if((nu->type & 7)==CU_NURBS) {
- /* de knots omkeren */
+ /* inverse knots */
a= KNOTSU(nu);
fp1= nu->knotsu;
fp2= fp1+(a-1);
fp1++;
fp2--;
}
- /* en weer in stijgende lijn maken */
+ /* and make in increasing order again */
a= KNOTSU(nu);
fp1= nu->knotsu;
fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect");
-/* displist.c GRAPHICS
+/* displist.c
*
- *
- * maart 95
*
* $Id$
*
if(G.scene->camera==0) G.scene->camera= scene_find_camera(G.scene);
if(G.scene->camera==0) return;
- /* uit roteerscene gejat */
+ /* copied from 'roteerscene' (does that function still exist? (ton) */
where_is_object(G.scene->camera);
Mat4CpyMat4(R.viewinv, G.scene->camera->obmat);
Mat4Ortho(R.viewinv);
i= 1.0;
soft= 1.0;
if(t<fl->spotbl && fl->spotbl!=0.0) {
- /* zachte gebied */
+ /* soft area */
i= t/fl->spotbl;
t= i*i;
soft= (3.0*t-2.0*t*i);
Mat4Invert(tmat, mat);
Mat3CpyMat4(imat, tmat);
- /* we halen de dl_verts eruit, deform info */
+ /* we extract dl_verts, deform info */
dldeform= find_displist(&ob->disp, DL_VERTS);
if(dldeform) BLI_remlink(&ob->disp, dldeform);
- /* Metaballs hebben de standaard displist aan het Object zitten */
+ /* Metaballs have the standard displist in the Object */
if(ob->type!=OB_MBALL) freedisplist(&ob->disp);
if((R.flag & R_RENDERING)==0) {
col2= dl->col2= MEM_mallocN(4*sizeof(int)*me->totface, "col2");
}
- /* even geen puno's */
+ /* no vertexnormals now */
mvert= me->mvert;
a= me->totvert;
while(FALSE || a--) {
}
else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
- /* nu hebben we wel de normalen nodig */
+ /* now we need the normals */
cu= ob->data;
dl= cu->disp.first;
if(dl->type==DL_INDEX3) {
if(dl->nors) {
- /* er is maar 1 normaal */
+ /* there's just one normal */
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];
}
}
else if(ob->type==OB_MBALL) {
- /* normalen zijn er al */
+ /* there are normals already */
dl= ob->disp.first;
while(dl) {
}
}
- /* deze was er tijdelijk uitgehaald */
+ /* this one was temporally removed */
if(dldeform) BLI_addtail(&ob->disp, dldeform);
}
ob= base->object;
- /* we halen de dl_verts eruit, deform info */
+ /* we extract dl_verts, deform info */
dldeform= find_displist(&ob->disp, DL_VERTS);
if(dldeform) BLI_remlink(&ob->disp, dldeform);
- /* Metaballs hebben de standaard displist aan het Object zitten */
+ /* Metaballs have standard displist at the Object */
if(ob->type==OB_MBALL) shadeDispList(ob);
else freedisplist(&ob->disp);
if(nu->hide==0) {
if((nu->type & 7)==CU_BEZIER) {
- /* tellen */
+ /* count */
len= 0;
a= nu->pntsu-1;
if(nu->flagu & 1) a++;
}
dl= MEM_callocN(sizeof(DispList), "makeDispListbez");
- /* len+1 i.v.m. maakbez */
+ /* len+1 because of 'maakbez' function */
dl->verts= MEM_callocN( (len+1)*3*sizeof(float), "dlverts");
BLI_addtail(dispbase, dl);
dl->parts= 1;
colnr= dl->col;
- /* editverts en edges maken */
+ /* make editverts and edges */
f1= dl->verts;
a= dl->nr;
eve= v1= 0;
if(totvert && BLI_edgefill(0)!=0) {
- /* vlakken tellen */
+ /* count faces (vlak in dutch!) */
tot= 0;
evl= fillvlakbase.first;
while(evl) {
dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex");
dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts");
- /* vertdata */
+ /* vert data */
f1= dlnew->verts;
totvert= 0;
eve= fillvertbase.first;
VECCOPY(f1, eve->co);
f1+= 3;
- /* indexnummer */
+ /* index number */
eve->vn= (EditVert *)totvert;
totvert++;
eve= eve->next;
}
- /* indexdata */
+ /* index data */
evl= fillvlakbase.first;
index= dlnew->index;
while(evl) {
colnr++;
}
- /* poly's niet vrijgeven. nodig voor wireframe display */
+ /* do not free polys, needed for wireframe display */
/* same as above ... */
/* if(G.f & G_PLAYANIM == 0) waitcursor(0); */
if(nu->flagv & 1) dl->flag|= 2;
}
else {
- dl->parts= nu->resolu; /* andersom want makeNurbfaces gaat zo */
+ dl->parts= nu->resolu; /* in reverse, because makeNurbfaces works that way */
dl->nr= nu->resolv;
- if(nu->flagv & 1) dl->flag|= 1; /* ook andersom ! */
+ if(nu->flagv & 1) dl->flag|= 1; /* reverse too! */
if(nu->flagu & 1) dl->flag|= 2;
}
dl->col= nu->mat_nr;
if(ob->dt!=0) makebevelcurve(ob, &dlbev);
}
- /* met bevellist werken */
+ /* work with bevellist */
widfac= cu->width-1.0;
bl= cu->bev.first;
nu= cu->nurb.first;
}
}
else {
- /* voor iedere stuk van de bevel een aparte dispblok maken */
+ /* for each part of the bevel use a separate displblock */
dlb= dlbev.first;
while(dlb) {
dl= MEM_callocN(sizeof(DispList), "makeDispListbev1");
data= dl->verts;
bevp= (BevPoint *)(bl+1);
a= bl->nr;
- while(a--) { /* voor ieder punt van poly een bevelstuk maken */
+ while(a--) { /* for each point of poly make a bevel piece */
- /* roteer bevelstuk en schrijf in data */
+ /* rotate bevel piece and write in data */
fp1= dlb->verts;
b= dlb->nr;
} Sample;
typedef struct Segment{
- /* coordinaten */
+ /* coordinates */
struct Segment * next, * prev;
float co[2];
} Segment;
int startx = 0, starty = 0;
Sample * samp, * oldsamp;
- /* wat erin gaat:
- * 1 - plaatje waarvan outline berekent moet worden,
- * 2 - pointer naar functie die bepaalt welke pixel in of uit is
+ /* input:
+ * 1 - image
+ * 2 - pointer to function that defines which pixel 'in' or 'out' is
*/
if (ibuf == 0) return (0);
if (in_or_out == 0) in_or_out = dflt_in_out;
in = in_or_out(ibuf, 0, 0);
- /* zoek naar eerste overgang en ga van daar uit 'zoeken' */
+ /* search for first transition, and continue from there */
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
if (in_or_out(ibuf, x, y) != in) {
- /* eerste 'andere' punt gevonden !! */
+ /* found first 'other' point !! */
if (x != startx) dir = 0;
else dir = 6;
}
if (i >= 8) {
- /* dit moet een losse punt geweest zijn */
+ /* this has to be a loose point */
break;
}
} while(x != startx || y != starty);
if (i >= 8) {
- /* losse punten patch */
+ /* patch for loose points */
MEM_freeN(samp);
} else {
count = count - 1;
}
}
}
- /* printf("geen overgang \n"); */
+ /* printf("no transition \n"); */
return(0);
}
/*******************************/
-static float DistToLine2D(short *v1, short *v2, short *v3) /* met formule van Hesse :GEEN LIJNSTUK! */
+static float DistToLine2D(short *v1, short *v2, short *v3) /* using Hesse formula :NO LINE PIECE! */
{
float a[2],deler;
int count;
Sample * samp;
- /* eerst een lijst met samples maken */
+ /* first make a list of samples */
samp = outline(ibuf, 0);
if (samp == 0) return;
if(ma && ma->mtex[0] && ma->mtex[0]->tex) {
tex= ma->mtex[0]->tex;
- /* dit zorgt voor correct laden van nieuwe imbufs */
+ /* this takes care of correct loading of new imbufs */
externtex(ma->mtex[0], vec);
if(tex->type==TEX_IMAGE && tex->ima && tex->ima->ibuf) {
-/* effect.c MIX MODEL
+/* effect.c
*
- * dec 95
*
* $Id$
*
void copy_act_effect(Object *ob)
{
- /* return de aktieve eff gekopieerd */
+ /* return a copy of the active effect */
Effect *effn, *eff;
eff= ob->effect.first;
eff= eff->next;
}
- /* als tie hier komt: new effect */
+ /* when it comes here: add new effect */
eff= add_effect(EFF_BUILD);
BLI_addtail(&ob->effect, eff);
static Particle *pa;
static int cur;
- /* afspraak: als paf->keys==0: alloc */
+ /* we agree: when paf->keys==0: alloc */
if(paf->keys==0) {
pa= paf->keys= MEM_callocN( paf->totkey*paf->totpart*sizeof(Particle), "particlekeys" );
cur= 0;
return;
}
- /* eerst op zoek naar de eerste particlekey */
+ /* first find the first particlekey */
a= (int)((paf->totkey-1)*(ctime-pa->time)/pa->lifetime);
if(a>=paf->totkey) a= paf->totkey-1;
damp= 1.0f-paf->damp;
pa= part;
- /* startsnelheid: random */
+ /* start speed: random */
if(paf->randfac!=0.0) {
pa->no[0]+= (float)(paf->randfac*( BLI_drand() -0.5));
pa->no[1]+= (float)(paf->randfac*( BLI_drand() -0.5));
pa->no[2]+= (float)(paf->randfac*( BLI_drand() -0.5));
}
- /* startsnelheid: texture */
+ /* start speed: texture */
if(mtex && paf->texfac!=0.0) {
particle_tex(mtex, paf, pa->co, pa->no);
}
b= paf->totkey-1;
while(b--) {
- /* nieuwe tijd */
+ /* new time */
pa->time= opa->time+deltalife;
- /* nieuwe plek */
+ /* new location */
pa->co[0]= opa->co[0] + deltalife*opa->no[0];
pa->co[1]= opa->co[1] + deltalife*opa->no[1];
pa->co[2]= opa->co[2] + deltalife*opa->no[2];
- /* nieuwe snelheid */
+ /* new speed */
pa->no[0]= opa->no[0] + deltalife*force[0];
pa->no[1]= opa->no[1] + deltalife*force[1];
pa->no[2]= opa->no[2] + deltalife*force[2];
- /* snelheid: texture */
+ /* speed: texture */
if(mtex && paf->texfac!=0.0) {
particle_tex(mtex, paf, pa->co, pa->no);
}
opa= pa;
pa++;
- /* opa wordt onderin ook gebruikt */
+ /* opa is used later on too! */
}
if(deform) {
- /* alle keys deformen */
+ /* deform all keys */
pa= part;
b= paf->totkey;
while(b--) {
disable_speed_curve(1);
- /* alle particles genereren */
+ /* generate all particles */
if(paf->keys) MEM_freeN(paf->keys);
paf->keys= 0;
new_particle(paf);
sfraont= ob->sf;
ob->sf= 0.0;
- /* mult generaties? */
+ /* mult generations? */
totpart= paf->totpart;
for(a=0; a<PAF_MAXMULT; a++) {
if(paf->mult[a]!=0.0) {
- /* interessante formule! opdezewijze is na 'x' generaties het totale aantal paf->totpart */
+ /* interessant formula! this way after 'x' generations the total is paf->totpart */
totpart= (int)(totpart / (1.0+paf->mult[a]*paf->child[a]));
}
else break;
ftime= paf->sta;
dtime= (paf->end - paf->sta)/totpart;
- /* hele hiera onthouden */
+ /* remember full hierarchy */
par= ob;
while(par) {
pushdata(par, sizeof(Object));
par= par->parent;
}
- /* alles op eerste frame zetten */
+ /* set it all at first frame */
G.scene->r.cfra= cfralast= (int)floor(ftime);
par= ob;
while(par) {
BLI_srand(paf->seed);
- /* gaat anders veuls te hard */
+ /* otherwise it goes way too fast */
force[0]= paf->force[0]*0.05f;
force[1]= paf->force[1]*0.05f;
force[2]= paf->force[2]*0.05f;
pa= new_particle(paf);
pa->time= ftime;
- /* ob op juiste tijd zetten */
+ /* set ob at correct time */
if((paf->flag & PAF_STATIC)==0) {
- cur= (int)floor(ftime) + 1 ; /* + 1 heeft een reden: (obmat/prevobmat) anders beginnen b.v. komeetstaartjes te laat */
+ cur= (int)floor(ftime) + 1 ; /* + 1 has a reason: (obmat/prevobmat) otherwise comet-tails start too late */
if(cfralast != cur) {
G.scene->r.cfra= cfralast= cur;
- /* later bijgevoegd: blur? */
+ /* added later: blur? */
bsystem_time(ob, ob->parent, (float)G.scene->r.cfra, 0.0);
par= ob;
Mat3CpyMat4(imat, ob->imat);
}
}
- /* coordinaat ophalen */
+ /* get coordinates */
if(paf->flag & PAF_FACE) give_mesh_mvert(me, a, co, no);
else {
mvert= me->mvert + (a % me->totvert);
VECCOPY(vec, co);
Mat4MulVecfl(prevobmat, vec);
- /* eerst even startsnelheid: object */
+ /* first start speed: object */
VecSubf(pa->no, pa->co, vec);
VecMulf(pa->no, paf->obfac);
- /* nu juiste interframe co berekenen */
+ /* calculate the correct inter-frame */
fac= (ftime- (float)floor(ftime));
pa->co[0]= fac*pa->co[0] + (1.0f-fac)*vec[0];
pa->co[1]= fac*pa->co[1] + (1.0f-fac)*vec[1];
pa->co[2]= fac*pa->co[2] + (1.0f-fac)*vec[2];
}
-
- /* startsnelheid: normaal */
+
+ /* start speed: normal */
if(paf->normfac!=0.0) {
/* sp= mvert->no; */
/* transpose ! */
give_mesh_mvert(0, 0, 0, 0);
- /* hele hiera terug */
+ /* put hierarchy back */
par= ob;
while(par) {
popfirst(par);
- /* geen ob->ipo doen: insertkey behouden */
+ /* do not do ob->ipo: keep insertkey */
do_ob_key(par);
par= par->parent;
}
- /* restore: NA popfirst */
+ /* restore: AFTER popfirst */
ob->sf= sfraont;
disable_speed_curve(0);
void calc_wave_deform(WaveEff *wav, float ctime, float *co)
{
- /* co is in lokale coords */
+ /* co is in local coords */
float lifefac, x, y, amplit;
- /* mag eigenlijk niet voorkomen */
+ /* actually this should not happen */
if((wav->flag & (WAV_X+WAV_Y))==0) return;
lifefac= wav->height;
}
else amplit= y;
- /* zo maaktie mooie cirkels */
+ /* this way it makes nice circles */
amplit-= (ctime-wav->timeoffs)*wav->speed;
if(wav->flag & WAV_CYCL) {
float *fp, ctime;
int a, first;
- /* is er een mave */
+ /* is there a wave */
wav= ob->effect.first;
while(wav) {
if(wav->type==EFF_WAVE) break;
while(wav) {
if(wav->type==EFF_WAVE) {
- /* voorberekenen */
+ /* precalculate */
wav->minfac= (float)(1.0/exp(wav->width*wav->narrow*wav->width*wav->narrow));
if(wav->damp==0) wav->damp= 10.0f;