216
220
v1->index= index;
218
222
fp1= RE_vertren_get_sticky(obr, ver, 0);
220
224
fp2= RE_vertren_get_sticky(obr, v1, 1);
221
225
memcpy(fp2, fp1, RE_STICKY_ELEMS*sizeof(float));
223
227
fp1= RE_vertren_get_stress(obr, ver, 0);
225
229
fp2= RE_vertren_get_stress(obr, v1, 1);
226
230
memcpy(fp2, fp1, RE_STRESS_ELEMS*sizeof(float));
228
232
fp1= RE_vertren_get_rad(obr, ver, 0);
230
234
fp2= RE_vertren_get_rad(obr, v1, 1);
231
235
memcpy(fp2, fp1, RE_RAD_ELEMS*sizeof(float));
233
237
fp1= RE_vertren_get_strand(obr, ver, 0);
235
239
fp2= RE_vertren_get_strand(obr, v1, 1);
236
240
memcpy(fp2, fp1, RE_STRAND_ELEMS*sizeof(float));
238
242
fp1= RE_vertren_get_tangent(obr, ver, 0);
240
244
fp2= RE_vertren_get_tangent(obr, v1, 1);
241
245
memcpy(fp2, fp1, RE_TANGENT_ELEMS*sizeof(float));
259
263
temp= obr->vertnodes;
261
265
obr->vertnodes= MEM_mallocN(sizeof(VertTableNode)*(obr->vertnodeslen+TABLEINITSIZE) , "vertnodes");
262
if(temp) memcpy(obr->vertnodes, temp, obr->vertnodeslen*sizeof(VertTableNode));
266
if (temp) memcpy(obr->vertnodes, temp, obr->vertnodeslen*sizeof(VertTableNode));
263
267
memset(obr->vertnodes+obr->vertnodeslen, 0, TABLEINITSIZE*sizeof(VertTableNode));
265
269
obr->vertnodeslen+=TABLEINITSIZE;
266
if(temp) MEM_freeN(temp);
270
if (temp) MEM_freeN(temp);
269
273
v= obr->vertnodes[a].vert;
273
277
v= (VertRen *)MEM_callocN(256*sizeof(VertRen),"findOrAddVert");
274
278
obr->vertnodes[a].vert= v;
276
for(i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) {
280
for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) {
422
426
surfnor= RE_vlakren_get_surfnor(obr, vlr, 0);
424
428
surfnor1= RE_vlakren_get_surfnor(obr, vlr1, 1);
425
VECCOPY(surfnor1, surfnor);
429
copy_v3_v3(surfnor1, surfnor);
428
432
tangent= RE_vlakren_get_nmap_tangent(obr, vlr, 0);
430
434
tangent1= RE_vlakren_get_nmap_tangent(obr, vlr1, 1);
431
435
memcpy(tangent1, tangent, sizeof(float)*RE_NMAP_TANGENT_ELEMS);
434
438
radface= RE_vlakren_get_radface(obr, vlr, 0);
436
440
radface1= RE_vlakren_get_radface(obr, vlr1, 1);
437
441
*radface1= *radface;
443
int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, float *nor)
447
void RE_vlakren_get_normal(Render *UNUSED(re), ObjectInstanceRen *obi, VlakRen *vlr, float *nor)
445
float v1[3], (*nmat)[3]= obi->nmat;
449
float (*nmat)[3]= obi->nmat;
448
if(obi->flag & R_TRANSFORMED) {
449
VECCOPY(nor, vlr->n);
451
mul_m3_v3(nmat, nor);
451
if (obi->flag & R_TRANSFORMED) {
452
mul_v3_m3v3(nor, nmat, vlr->n);
452
453
normalize_v3(nor);
455
VECCOPY(nor, vlr->n);
457
if((vlr->flag & R_NOPUNOFLIP)==0) {
458
if(re->r.mode & R_ORTHO) {
463
VECCOPY(v1, vlr->v1->co);
464
if(obi->flag & R_TRANSFORMED)
465
mul_m4_v3(obi->mat, v1);
466
if(INPR(v1, nor) < 0.0f) {
456
copy_v3_v3(nor, vlr->n);
481
460
void RE_set_customdata_names(ObjectRen *obr, CustomData *data)
483
462
/* CustomData layer names are stored per object here, because the
484
DerivedMesh which stores the layers is freed */
463
* DerivedMesh which stores the layers is freed */
486
465
CustomDataLayer *layer;
487
466
int numtf = 0, numcol = 0, i, mtfn, mcn;
521
500
printf("error in findOrAddVlak: %d\n",nr);
522
501
return obr->vlaknodes[0].vlak;
526
if (a>=obr->vlaknodeslen-1){ /* Need to allocate more columns..., and keep last element NULL for free loop */
505
if (a>=obr->vlaknodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
527
506
temp= obr->vlaknodes;
529
508
obr->vlaknodes= MEM_mallocN(sizeof(VlakTableNode)*(obr->vlaknodeslen+TABLEINITSIZE) , "vlaknodes");
530
if(temp) memcpy(obr->vlaknodes, temp, obr->vlaknodeslen*sizeof(VlakTableNode));
509
if (temp) memcpy(obr->vlaknodes, temp, obr->vlaknodeslen*sizeof(VlakTableNode));
531
510
memset(obr->vlaknodes+obr->vlaknodeslen, 0, TABLEINITSIZE*sizeof(VlakTableNode));
533
512
obr->vlaknodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
534
if(temp) MEM_freeN(temp);
513
if (temp) MEM_freeN(temp);
537
516
v= obr->vlaknodes[a].vlak;
542
521
v= (VlakRen *)MEM_callocN(256*sizeof(VlakRen),"findOrAddVlak");
543
522
obr->vlaknodes[a].vlak= v;
545
for(i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++)
524
for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++)
692
671
printf("error in findOrAddStrand: %d\n",nr);
693
672
return obr->strandnodes[0].strand;
697
if (a>=obr->strandnodeslen-1){ /* Need to allocate more columns..., and keep last element NULL for free loop */
676
if (a>=obr->strandnodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
698
677
temp= obr->strandnodes;
700
679
obr->strandnodes= MEM_mallocN(sizeof(StrandTableNode)*(obr->strandnodeslen+TABLEINITSIZE) , "strandnodes");
701
if(temp) memcpy(obr->strandnodes, temp, obr->strandnodeslen*sizeof(StrandTableNode));
680
if (temp) memcpy(obr->strandnodes, temp, obr->strandnodeslen*sizeof(StrandTableNode));
702
681
memset(obr->strandnodes+obr->strandnodeslen, 0, TABLEINITSIZE*sizeof(StrandTableNode));
704
683
obr->strandnodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
705
if(temp) MEM_freeN(temp);
684
if (temp) MEM_freeN(temp);
708
687
v= obr->strandnodes[a].strand;
713
692
v= (StrandRen *)MEM_callocN(256*sizeof(StrandRen),"findOrAddStrand");
714
693
obr->strandnodes[a].strand= v;
716
for(i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++)
695
for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++)
783
if(vlaknodes==NULL) return;
762
if (vlaknodes==NULL) return;
785
for(a=0; vlaknodes[a].vlak; a++) {
764
for (a=0; vlaknodes[a].vlak; a++) {
786
765
MEM_freeN(vlaknodes[a].vlak);
788
if(vlaknodes[a].mtface)
767
if (vlaknodes[a].mtface)
789
768
MEM_freeN(vlaknodes[a].mtface);
790
if(vlaknodes[a].mcol)
769
if (vlaknodes[a].mcol)
791
770
MEM_freeN(vlaknodes[a].mcol);
792
if(vlaknodes[a].surfnor)
771
if (vlaknodes[a].surfnor)
793
772
MEM_freeN(vlaknodes[a].surfnor);
794
if(vlaknodes[a].tangent)
773
if (vlaknodes[a].tangent)
795
774
MEM_freeN(vlaknodes[a].tangent);
796
if(vlaknodes[a].radface)
775
if (vlaknodes[a].radface)
797
776
MEM_freeN(vlaknodes[a].radface);
800
779
MEM_freeN(vlaknodes);
803
void free_renderdata_strandnodes(StrandTableNode *strandnodes)
782
static void free_renderdata_strandnodes(StrandTableNode *strandnodes)
807
if(strandnodes==NULL) return;
786
if (strandnodes==NULL) return;
809
for(a=0; strandnodes[a].strand; a++) {
788
for (a=0; strandnodes[a].strand; a++) {
810
789
MEM_freeN(strandnodes[a].strand);
812
if(strandnodes[a].uv)
791
if (strandnodes[a].uv)
813
792
MEM_freeN(strandnodes[a].uv);
814
if(strandnodes[a].mcol)
793
if (strandnodes[a].mcol)
815
794
MEM_freeN(strandnodes[a].mcol);
816
if(strandnodes[a].winspeed)
795
if (strandnodes[a].winspeed)
817
796
MEM_freeN(strandnodes[a].winspeed);
818
if(strandnodes[a].surfnor)
797
if (strandnodes[a].surfnor)
819
798
MEM_freeN(strandnodes[a].surfnor);
820
if(strandnodes[a].simplify)
799
if (strandnodes[a].simplify)
821
800
MEM_freeN(strandnodes[a].simplify);
822
if(strandnodes[a].face)
801
if (strandnodes[a].face)
823
802
MEM_freeN(strandnodes[a].face);
856
835
obr->blohalen= 0;
859
if(obr->strandnodes) {
838
if (obr->strandnodes) {
860
839
free_renderdata_strandnodes(obr->strandnodes);
861
840
obr->strandnodes= NULL;
862
841
obr->strandnodeslen= 0;
865
844
strandbuf= obr->strandbuf;
867
if(strandbuf->vert) MEM_freeN(strandbuf->vert);
868
if(strandbuf->bound) MEM_freeN(strandbuf->bound);
846
if (strandbuf->vert) MEM_freeN(strandbuf->vert);
847
if (strandbuf->bound) MEM_freeN(strandbuf->bound);
869
848
MEM_freeN(strandbuf);
873
852
MEM_freeN(obr->mtface);
875
855
MEM_freeN(obr->mcol);
879
858
MEM_freeN(obr->rayfaces);
880
859
obr->rayfaces = NULL;
882
if(obr->rayprimitives)
862
if (obr->rayprimitives) {
884
863
MEM_freeN(obr->rayprimitives);
885
864
obr->rayprimitives = NULL;
889
868
RE_rayobject_free(obr->raytree);
890
869
obr->raytree = NULL;
894
if(re->objectinstance) {
895
for(obi=re->instancetable.first; obi; obi=obi->next)
873
if (re->objectinstance) {
874
for (obi=re->instancetable.first; obi; obi=obi->next)
898
877
MEM_freeN(obi->vectors);
901
880
RE_rayobject_free(obi->raytree);
924
903
HaloRen *h, **temp;
928
907
printf("error in findOrAddHalo: %d\n",nr);
933
if (a>=obr->blohalen-1){ /* Need to allocate more columns..., and keep last element NULL for free loop */
912
if (a>=obr->blohalen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
934
913
//printf("Allocating %i more halo groups. %i total.\n",
935
914
// TABLEINITSIZE, obr->blohalen+TABLEINITSIZE );
938
917
obr->bloha=(HaloRen**)MEM_callocN(sizeof(void*)*(obr->blohalen+TABLEINITSIZE) , "Bloha");
939
if(temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void*));
918
if (temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void*));
940
919
memset(&(obr->bloha[obr->blohalen]), 0, TABLEINITSIZE*sizeof(void*));
941
920
obr->blohalen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
942
if(temp) MEM_freeN(temp);
921
if (temp) MEM_freeN(temp);
945
924
h= obr->bloha[a];
947
926
h= (HaloRen *)MEM_callocN(256*sizeof(HaloRen),"findOrAdHalo");
948
927
obr->bloha[a]= h;
961
940
float tin, tr, tg, tb, ta;
962
941
float xn, yn, zn, texvec[3], hoco[4], hoco1[4];
964
if(hasize==0.0) return NULL;
943
if (hasize==0.0f) return NULL;
966
945
projectverto(vec, re->winmat, hoco);
967
if(hoco[3]==0.0) return NULL;
946
if (hoco[3]==0.0f) return NULL;
969
948
projectverto(vec1, re->winmat, hoco1);
970
if(hoco1[3]==0.0) return NULL;
949
if (hoco1[3]==0.0f) return NULL;
973
952
har= RE_findOrAddHalo(obr, obr->tothalo++);
974
VECCOPY(har->co, vec);
953
copy_v3_v3(har->co, vec);
975
954
har->hasize= hasize;
977
956
/* actual projectvert is done in function project_renderdata() because of parts/border/pano */
978
957
/* we do it here for sorting of halos */
980
har->xs= 0.5*re->winx*(hoco[0]/zn);
981
har->ys= 0.5*re->winy*(hoco[1]/zn);
959
har->xs= 0.5f*re->winx*(hoco[0]/zn);
960
har->ys= 0.5f*re->winy*(hoco[1]/zn);
982
961
har->zs= 0x7FFFFF*(hoco[2]/zn);
984
963
har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
989
968
har->type |= HA_VECT;
991
xn= har->xs - 0.5*re->winx*(hoco1[0]/hoco1[3]);
992
yn= har->ys - 0.5*re->winy*(hoco1[1]/hoco1[3]);
993
if(xn==0.0 || (xn==0.0 && yn==0.0)) zn= 0.0;
970
xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]);
971
yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]);
972
if (xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0f;
994
973
else zn= atan2(yn, xn);
996
975
har->sin= sin(zn);
997
976
har->cos= cos(zn);
998
977
zn= len_v3v3(vec1, vec);
1000
har->hasize= vectsize*zn + (1.0-vectsize)*hasize;
979
har->hasize= vectsize*zn + (1.0f-vectsize)*hasize;
1002
981
sub_v3_v3v3(har->no, vec, vec1);
1003
982
normalize_v3(har->no);
1006
if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
985
if (ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
1008
987
har->alfa= ma->alpha;
1012
har->add= (255.0*ma->add);
991
har->add= (255.0f*ma->add);
1014
993
har->hard= ma->har;
1015
994
har->seed= seed % 256;
1017
if(ma->mode & MA_STAR) har->starpoints= ma->starc;
1018
if(ma->mode & MA_HALO_LINES) har->linec= ma->linec;
1019
if(ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc;
1020
if(ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec;
1025
if( (ma->mode & MA_HALOTEX) ) har->tex= 1;
996
if (ma->mode & MA_STAR) har->starpoints= ma->starc;
997
if (ma->mode & MA_HALO_LINES) har->linec= ma->linec;
998
if (ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc;
999
if (ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec;
1004
if ( (ma->mode & MA_HALOTEX) ) har->tex= 1;
1005
else if (har->mat->septex & (1<<0)); /* only 1 level textures */
1028
1008
mtex= ma->mtex[0];
1029
VECCOPY(texvec, vec);
1009
copy_v3_v3(texvec, vec);
1031
if(mtex->texco & TEXCO_NORM) {
1011
if (mtex->texco & TEXCO_NORM) {
1034
else if(mtex->texco & TEXCO_OBJECT) {
1014
else if (mtex->texco & TEXCO_OBJECT) {
1035
1015
/* texvec[0]+= imatbase->ivec[0]; */
1036
1016
/* texvec[1]+= imatbase->ivec[1]; */
1037
1017
/* texvec[2]+= imatbase->ivec[2]; */
1038
1018
/* mul_m3_v3(imatbase->imat, texvec); */
1042
VECCOPY(texvec, orco);
1022
copy_v3_v3(texvec, orco);
1046
externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta);
1026
externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0);
1048
1028
yn= tin*mtex->colfac;
1049
zn= tin*mtex->alphafac;
1029
//zn= tin*mtex->alphafac;
1051
if(mtex->mapto & MAP_COL) {
1031
if (mtex->mapto & MAP_COL) {
1053
1033
har->r= (yn*tr+ zn*ma->r);
1054
1034
har->g= (yn*tg+ zn*ma->g);
1055
1035
har->b= (yn*tb+ zn*ma->b);
1057
if(mtex->texco & TEXCO_UV) {
1037
if (mtex->texco & TEXCO_UV) {
1058
1038
har->alfa= tin;
1060
if(mtex->mapto & MAP_ALPHA)
1040
if (mtex->mapto & MAP_ALPHA)
1061
1041
har->alfa= tin;
1068
1048
HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma, float *vec, float *vec1,
1069
float *orco, float *uvco, float hasize, float vectsize, int seed)
1049
float *orco, float *uvco, float hasize, float vectsize, int seed, float *pa_co)
1073
1053
float tin, tr, tg, tb, ta;
1074
1054
float xn, yn, zn, texvec[3], hoco[4], hoco1[4], in[3],tex[3],out[3];
1077
if(hasize==0.0) return NULL;
1057
if (hasize==0.0f) return NULL;
1079
1059
projectverto(vec, re->winmat, hoco);
1080
if(hoco[3]==0.0) return NULL;
1060
if (hoco[3]==0.0f) return NULL;
1082
1062
projectverto(vec1, re->winmat, hoco1);
1083
if(hoco1[3]==0.0) return NULL;
1063
if (hoco1[3]==0.0f) return NULL;
1086
1066
har= RE_findOrAddHalo(obr, obr->tothalo++);
1087
VECCOPY(har->co, vec);
1067
copy_v3_v3(har->co, vec);
1088
1068
har->hasize= hasize;
1090
1070
/* actual projectvert is done in function project_renderdata() because of parts/border/pano */
1091
1071
/* we do it here for sorting of halos */
1093
har->xs= 0.5*re->winx*(hoco[0]/zn);
1094
har->ys= 0.5*re->winy*(hoco[1]/zn);
1073
har->xs= 0.5f*re->winx*(hoco[0]/zn);
1074
har->ys= 0.5f*re->winy*(hoco[1]/zn);
1095
1075
har->zs= 0x7FFFFF*(hoco[2]/zn);
1097
1077
har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
1102
1082
har->type |= HA_VECT;
1104
xn= har->xs - 0.5*re->winx*(hoco1[0]/hoco1[3]);
1105
yn= har->ys - 0.5*re->winy*(hoco1[1]/hoco1[3]);
1106
if(xn==0.0 || (xn==0.0 && yn==0.0)) zn= 0.0;
1084
xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]);
1085
yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]);
1086
if (xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0;
1107
1087
else zn= atan2(yn, xn);
1109
1089
har->sin= sin(zn);
1110
1090
har->cos= cos(zn);
1111
zn= len_v3v3(vec1, vec)*0.5;
1091
zn= len_v3v3(vec1, vec)*0.5f;
1113
har->hasize= vectsize*zn + (1.0-vectsize)*hasize;
1093
har->hasize= vectsize*zn + (1.0f-vectsize)*hasize;
1115
1095
sub_v3_v3v3(har->no, vec, vec1);
1116
1096
normalize_v3(har->no);
1119
if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
1099
if (ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
1121
1101
har->alfa= ma->alpha;
1125
har->add= (255.0*ma->add);
1105
har->add= (255.0f*ma->add);
1127
1107
har->hard= ma->har;
1128
1108
har->seed= seed % 256;
1130
if(ma->mode & MA_STAR) har->starpoints= ma->starc;
1131
if(ma->mode & MA_HALO_LINES) har->linec= ma->linec;
1132
if(ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc;
1133
if(ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec;
1110
if (ma->mode & MA_STAR) har->starpoints= ma->starc;
1111
if (ma->mode & MA_HALO_LINES) har->linec= ma->linec;
1112
if (ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc;
1113
if (ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec;
1135
if((ma->mode & MA_HALOTEX) && ma->mtex[0]){
1115
if ((ma->mode & MA_HALOTEX) && ma->mtex[0])
1140
for(i=0; i<MAX_MTEX; i++)
1141
if(ma->mtex[i] && (ma->septex & (1<<i))==0) {
1118
for (i=0; i<MAX_MTEX; i++)
1119
if (ma->mtex[i] && (ma->septex & (1<<i))==0) {
1142
1120
mtex= ma->mtex[i];
1143
VECCOPY(texvec, vec);
1121
copy_v3_v3(texvec, vec);
1145
if(mtex->texco & TEXCO_NORM) {
1123
if (mtex->texco & TEXCO_NORM) {
1148
else if(mtex->texco & TEXCO_OBJECT) {
1151
/* imat should really be cached somewhere before this */
1152
invert_m4_m4(imat,mtex->object->obmat);
1153
mul_m4_v3(imat,texvec);
1155
/* texvec[0]+= imatbase->ivec[0]; */
1156
/* texvec[1]+= imatbase->ivec[1]; */
1157
/* texvec[2]+= imatbase->ivec[2]; */
1158
/* mul_m3_v3(imatbase->imat, texvec); */
1160
else if(mtex->texco & TEXCO_GLOB){
1161
VECCOPY(texvec,vec);
1163
else if(mtex->texco & TEXCO_UV && uvco){
1126
else if (mtex->texco & TEXCO_OBJECT) {
1128
mul_m4_v3(mtex->object->imat_ren,texvec);
1130
else if (mtex->texco & TEXCO_GLOB) {
1131
copy_v3_v3(texvec,vec);
1133
else if (mtex->texco & TEXCO_UV && uvco) {
1164
1134
int uv_index=CustomData_get_named_layer_index(&dm->faceData,CD_MTFACE,mtex->uvname);
1166
1136
uv_index=CustomData_get_active_layer_index(&dm->faceData,CD_MTFACE);
1168
1138
uv_index-=CustomData_get_layer_index(&dm->faceData,CD_MTFACE);
1171
1141
texvec[1]=2.0f*uvco[2*uv_index+1]-1.0f;
1172
1142
texvec[2]=0.0f;
1175
VECCOPY(texvec, orco);
1144
else if (mtex->texco & TEXCO_PARTICLE) {
1145
/* particle coordinates in range [0,1] */
1146
texvec[0] = 2.f * pa_co[0] - 1.f;
1147
texvec[1] = 2.f * pa_co[1] - 1.f;
1148
texvec[2] = pa_co[2];
1151
copy_v3_v3(texvec, orco);
1178
externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta);
1154
hasrgb = externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0);
1180
1156
//yn= tin*mtex->colfac;
1181
1157
//zn= tin*mtex->alphafac;
1182
if(mtex->mapto & MAP_COL) {
1158
if (mtex->mapto & MAP_COL) {
1199
if(mtex->mapto & MAP_ALPHA)
1176
/* alpha returned, so let's use it instead of intensity */
1180
if (mtex->mapto & MAP_ALPHA)
1200
1181
har->alfa = texture_value_blend(mtex->def_var,har->alfa,tin,mtex->alphafac,mtex->blendtype);
1201
if(mtex->mapto & MAP_HAR)
1202
har->hard = 1.0+126.0*texture_value_blend(mtex->def_var,((float)har->hard)/127.0,tin,mtex->hardfac,mtex->blendtype);
1203
if(mtex->mapto & MAP_RAYMIRR)
1204
har->hasize = 100.0*texture_value_blend(mtex->def_var,har->hasize/100.0,tin,mtex->raymirrfac,mtex->blendtype);
1182
if (mtex->mapto & MAP_HAR)
1183
har->hard = 1.0f+126.0f*texture_value_blend(mtex->def_var,((float)har->hard)/127.0f,tin,mtex->hardfac,mtex->blendtype);
1184
if (mtex->mapto & MAP_RAYMIRR)
1185
har->hasize = 100.0f*texture_value_blend(mtex->def_var,har->hasize/100.0f,tin,mtex->raymirrfac,mtex->blendtype);
1186
if (mtex->mapto & MAP_TRANSLU) {
1187
float add = texture_value_blend(mtex->def_var,(float)har->add/255.0f,tin,mtex->translfac,mtex->blendtype);
1188
CLAMP(add, 0.f, 1.f);
1189
har->add = 255.0f*add;
1205
1191
/* now what on earth is this good for?? */
1206
//if(mtex->texco & 16) {
1192
//if (mtex->texco & 16) {
1207
1193
// har->alfa= tin;
1223
if(do_pano==0) return testclip(v);
1209
if (do_pano==0) return testclip(v);
1225
1211
abs4= fabs(v[3]);
1227
if(v[2]< -abs4) c=16; /* this used to be " if(v[2]<0) ", see clippz() */
1228
else if(v[2]> abs4) c+= 32;
1213
if (v[2]< -abs4) c=16; /* this used to be " if (v[2]<0) ", see clippz() */
1214
else if (v[2]> abs4) c+= 32;
1230
if( v[1]>abs4) c+=4;
1231
else if( v[1]< -abs4) c+=8;
1216
if ( v[1]>abs4) c+=4;
1217
else if ( v[1]< -abs4) c+=8;
1233
1219
abs4*= re->xparts;
1234
if( v[0]>abs4) c+=2;
1235
else if( v[0]< -abs4) c+=1;
1220
if ( v[0]>abs4) c+=2;
1221
else if ( v[0]< -abs4) c+=1;
1241
This adds the hcs coordinates to vertices. It iterates over all
1242
vertices, halos and faces. After the conversion, we clip in hcs.
1244
Elsewhere, all primites are converted to vertices.
1246
- envmapping (envmap.c)
1247
- shadow buffering (shadbuf.c)
1250
void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4], float *), int do_pano, float xoffs, int do_buckets)
1227
* This adds the hcs coordinates to vertices. It iterates over all
1228
* vertices, halos and faces. After the conversion, we clip in hcs.
1230
* Elsewhere, all primites are converted to vertices.
1232
* - envmapping (envmap.c)
1233
* - shadow buffering (shadbuf.c)
1236
void project_renderdata(Render *re, void (*projectfunc)(const float *, float mat[][4], float *), int do_pano, float xoffs, int UNUSED(do_buckets))
1252
1238
ObjectRen *obr;
1253
1239
HaloRen *har = NULL;
1254
1240
float zn, vec[3], hoco[4];
1258
1244
float panophi= xoffs;
1260
1246
re->panosi= sin(panophi);
1261
1247
re->panoco= cos(panophi);
1264
for(obr=re->objecttable.first; obr; obr=obr->next) {
1250
for (obr=re->objecttable.first; obr; obr=obr->next) {
1265
1251
/* calculate view coordinates (and zbuffer value) */
1266
for(a=0; a<obr->tothalo; a++) {
1267
if((a & 255)==0) har= obr->bloha[a>>8];
1252
for (a=0; a<obr->tothalo; a++) {
1253
if ((a & 255)==0) har= obr->bloha[a>>8];
1271
1257
vec[0]= re->panoco*har->co[0] + re->panosi*har->co[2];
1272
1258
vec[1]= har->co[1];
1273
1259
vec[2]= -re->panosi*har->co[0] + re->panoco*har->co[2];
1276
VECCOPY(vec, har->co);
1262
copy_v3_v3(vec, har->co);
1279
1265
projectfunc(vec, re->winmat, hoco);
1281
1267
/* we clip halos less critical, but not for the Z */
1285
if( panotestclip(re, do_pano, hoco) ) {
1271
if ( panotestclip(re, do_pano, hoco) ) {
1286
1272
har->miny= har->maxy= -10000; /* that way render clips it */
1288
else if(hoco[3]<0.0) {
1274
else if (hoco[3]<0.0f) {
1289
1275
har->miny= har->maxy= -10000; /* render clips it */
1291
1277
else /* do the projection...*/
1293
1279
/* bring back hocos */
1298
har->xs= 0.5*re->winx*(1.0+hoco[0]/zn); /* the 0.5 negates the previous 2...*/
1299
har->ys= 0.5*re->winy*(1.0+hoco[1]/zn);
1284
har->xs= 0.5f*re->winx*(1.0f+hoco[0]/zn); /* the 0.5 negates the previous 2...*/
1285
har->ys= 0.5f*re->winy*(1.0f+hoco[1]/zn);
1301
1287
/* this should be the zbuffer coordinate */
1302
1288
har->zs= 0x7FFFFF*(hoco[2]/zn);
1405
1391
mul_m4_v4(mat, vec);
1409
if(vec[0] > bounds[1]*vec[3]) fl |= 1;
1410
if(vec[0]< bounds[0]*vec[3]) fl |= 2;
1411
if(vec[1] > bounds[3]*vec[3]) fl |= 4;
1412
if(vec[1]< bounds[2]*vec[3]) fl |= 8;
1395
if (vec[0] < bounds[0]*vec[3]) fl |= 1;
1396
else if (vec[0] > bounds[1]*vec[3]) fl |= 2;
1398
if (vec[1] > bounds[3]*vec[3]) fl |= 4;
1399
else if (vec[1]< bounds[2]*vec[3]) fl |= 8;
1415
if(vec[0] < -vec[3]) fl |= 1;
1416
if(vec[0] > vec[3]) fl |= 2;
1417
if(vec[1] < -vec[3]) fl |= 4;
1418
if(vec[1] > vec[3]) fl |= 8;
1402
if (vec[0] < -vec[3]) fl |= 1;
1403
else if (vec[0] > vec[3]) fl |= 2;
1405
if (vec[1] > vec[3]) fl |= 4;
1406
else if (vec[1] < -vec[3]) fl |= 8;
1420
if(vec[2] < -vec[3]) fl |= 16;
1421
if(vec[2] > vec[3]) fl |= 32;
1408
if (vec[2] < -vec[3]) fl |= 16;
1409
else if (vec[2] > vec[3]) fl |= 32;
1424
if(flag==0) return 0;
1412
if (flag==0) return 0;