Ray.cpp (pymol-v2.1.0.tar.bz2) | : | Ray.cpp (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 87 | skipping to change at line 87 | |||
unsigned int background; | unsigned int background; | |||
int border; | int border; | |||
int phase, n_thread; | int phase, n_thread; | |||
int x_start, x_stop; | int x_start, x_stop; | |||
int y_start, y_stop; | int y_start, y_stop; | |||
unsigned int *edging; | unsigned int *edging; | |||
unsigned int edging_cutoff; | unsigned int edging_cutoff; | |||
int perspective; | int perspective; | |||
float fov, pos[3]; | float fov, pos[3]; | |||
float *depth; | float *depth; | |||
int bgWidth, bgHeight; | ||||
void *bkrd_data; /* used for image-based background */ | ||||
}; | }; | |||
struct _CRayHashThreadInfo { | struct _CRayHashThreadInfo { | |||
CBasis *basis; | CBasis *basis; | |||
int *vert2prim; | int *vert2prim; | |||
CPrimitive *prim; | CPrimitive *prim; | |||
int n_prim; | int n_prim; | |||
float *clipBox; | float *clipBox; | |||
unsigned int *image; | unsigned int *image; | |||
unsigned int background; | unsigned int background; | |||
skipping to change at line 120 | skipping to change at line 123 | |||
unsigned int *image; | unsigned int *image; | |||
unsigned int *image_copy; | unsigned int *image_copy; | |||
unsigned int width, height; | unsigned int width, height; | |||
int mag; | int mag; | |||
int phase, n_thread; | int phase, n_thread; | |||
CRay *ray; | CRay *ray; | |||
}; | }; | |||
void RayRelease(CRay * I); | void RayRelease(CRay * I); | |||
void RaySetup(CRay * I); | ||||
static void RayApplyMatrix33(unsigned int n, float3 * q, const float m[16], floa t3 * p); | static void RayApplyMatrix33(unsigned int n, float3 * q, const float m[16], floa t3 * p); | |||
static void RayApplyMatrixInverse33(unsigned int n, float3 * q, const float m[16 ], float3 * p); | static void RayApplyMatrixInverse33(unsigned int n, float3 * q, const float m[16 ], float3 * p); | |||
int RayExpandPrimitives(CRay * I); | int RayExpandPrimitives(CRay * I); | |||
int PrimitiveSphereHit(CRay * I, float *v, float *n, float *minDist, int except) ; | int PrimitiveSphereHit(CRay * I, float *v, float *n, float *minDist, int except) ; | |||
static void RayTransformNormals33(unsigned int n, float3 * q, const float m[16], float3 * p); | static void RayTransformNormals33(unsigned int n, float3 * q, const float m[16], float3 * p); | |||
static void RayTransformInverseNormals33(unsigned int n, float3 * q, const float m[16], | static void RayTransformInverseNormals33(unsigned int n, float3 * q, const float m[16], | |||
float3 * p); | float3 * p); | |||
void RayProjectTriangle(CRay * I, RayInfo * r, float *light, float *v0, float *n 0, | void RayProjectTriangle(CRay * I, RayInfo * r, float *light, float *v0, float *n 0, | |||
float scale); | float scale); | |||
void RaySetContext(CRay * I, int context) | void RaySetContext(CRay * I, int context) | |||
{ | { | |||
if(context >= 0) | if(context >= 0) | |||
I->Context = context; | I->Context = context; | |||
else | else | |||
I->Context = 0; | I->Context = 0; | |||
} | } | |||
static float RayGetScreenVertexScale(CRay * I, float *v1) | float RayGetScreenVertexScale(CRay * I, float *v1) | |||
{ | { | |||
/* what size should a screen pixel be at the coordinate provided? */ | /* what size should a screen pixel be at the coordinate provided? */ | |||
float vt[3]; | float vt[3]; | |||
float ratio; | float ratio; | |||
RayApplyMatrix33(1, (float3 *) vt, I->ModelView, (float3 *) v1); | RayApplyMatrix33(1, (float3 *) vt, I->ModelView, (float3 *) v1); | |||
if(I->Ortho) { | if(I->Ortho) { | |||
ratio = | ratio = | |||
2 * (float) (fabs(I->Pos[2]) * tan((I->Fov / 2.0) * cPI / 180.0)) / (I->He ight); | 2 * (float) (fabs(I->Pos[2]) * tan((I->Fov / 2.0) * cPI / 180.0)) / (I->He ight); | |||
} else { | } else { | |||
float front_size = | float front_size = | |||
2 * I->Volume[4] * ((float) tan((I->Fov / 2.0F) * PI / 180.0F)) / (I->Heig ht); | 2 * I->Volume[4] * ((float) tan((I->Fov / 2.0F) * PI / 180.0F)) / (I->Heig ht); | |||
ratio = front_size * (-vt[2] / I->Volume[4]); | ratio = fabs(front_size * (-vt[2] / I->Volume[4])); | |||
} | } | |||
return ratio; | return ratio; | |||
} | } | |||
static void RayApplyContextToVertex(CRay * I, float *v) | static void RayApplyContextToVertex(CRay * I, float *v) | |||
{ | { | |||
switch (I->Context) { | switch (I->Context) { | |||
case 1: | case 1: | |||
{ | { | |||
float tw; | float tw; | |||
skipping to change at line 263 | skipping to change at line 265 | |||
static void fill(unsigned int *buffer, unsigned int value, size_t cnt) | static void fill(unsigned int *buffer, unsigned int value, size_t cnt) | |||
{ | { | |||
// std::fill_n(buffer, cnt, value); | // std::fill_n(buffer, cnt, value); | |||
for (auto it_end = buffer + cnt; buffer != it_end;) { | for (auto it_end = buffer + cnt; buffer != it_end;) { | |||
*(buffer++) = value; | *(buffer++) = value; | |||
} | } | |||
} | } | |||
#define MIN(x,y) ((x < y) ? x : y) | #define MIN(x,y) ((x < y) ? x : y) | |||
#define MAX(x,y) ((x > y) ? x : y) | #define MAX(x,y) ((x > y) ? x : y) | |||
static void add4ucf(unsigned char *ucval, float *fval, float mulv){ | ||||
fval[0] += ucval[0] * mulv; | ||||
fval[1] += ucval[1] * mulv; | ||||
fval[2] += ucval[2] * mulv; | ||||
fval[3] += ucval[3] * mulv; | ||||
} | ||||
static void copy4fuc(float *fval, unsigned char *ucval){ | ||||
ucval[0] = (0xFF & (int)pymol_roundf(fval[0])); | ||||
ucval[1] = (0xFF & (int)pymol_roundf(fval[1])); | ||||
ucval[2] = (0xFF & (int)pymol_roundf(fval[2])); | ||||
ucval[3] = (0xFF & (int)pymol_roundf(fval[3])); | ||||
} | ||||
static float fmodpos(float a, float b){ | ||||
float ret = fmod(a, b); | ||||
if (ret < 0.f){ | ||||
ret = fmod(-ret, b); | ||||
ret = fmod( b - ret, b); | ||||
} | ||||
return ret; | ||||
} | ||||
static void compute_background_for_pixel(unsigned char *bkrd, short isOutsideInY | ||||
, | ||||
int bg_image_mode, const float *bg_image_tilesize, const float *bg_rgb, int | ||||
bg_image_linear, | ||||
unsigned char *bkgrd_data, int bkgrd_width, int bkgrd_height, float w, float | ||||
wr, | ||||
float hl, float hpixelx, short blend_bg) | ||||
{ | ||||
short isBackground = isOutsideInY; | ||||
float wl; | ||||
switch (bg_image_mode){ | ||||
case 1: // isCentered | ||||
{ | ||||
float tmpx = floor(w - hpixelx); | ||||
isBackground |= (tmpx < 0.f || tmpx > (float)bkgrd_width); | ||||
wl = fmodpos(tmpx, (float)bkgrd_width); | ||||
} | ||||
break; | ||||
case 2: // isTiled | ||||
wl = bkgrd_width * (fmodpos((float)w, bg_image_tilesize[0])/bg_image_tilesiz | ||||
e[0]); | ||||
break; | ||||
case 3: // isCenteredRepeated | ||||
wl = fmodpos(floor(w - hpixelx), (float)bkgrd_width) ; | ||||
break; | ||||
default: | ||||
wl = w * wr; | ||||
} | ||||
if (isBackground){ | ||||
copy3f(bg_rgb, bkrd); | ||||
bkrd[3] = 1.f; | ||||
} else if (bg_image_linear){ | ||||
int wlf = floor(wl), hlf = floor(hl); | ||||
float xp = (wl - wlf) - .5f, yp = (hl - hlf) - .5f; | ||||
float xpa = fabs(xp), ypa = fabs(yp); | ||||
float xpam = 1.f - xpa, ypam = 1.f - ypa; | ||||
float valx[4] = { 0.f, 0.f, 0.f, 0.f }, valy[4] = { 0.f, 0.f, 0.f, 0.f }, va | ||||
l[4] = { 0.f, 0.f, 0.f, 0.f }; | ||||
int xd = (xp > 0.f) ? 1 : -1, yd = (yp > 0.f) ? 1 : -1; | ||||
int wlfn = (wlf + xd + bkgrd_width) % bkgrd_width, hlfn = (hlf + yd + bkgrd_ | ||||
height) % bkgrd_height; | ||||
add4ucf(&bkgrd_data[(bkgrd_width*hlf + wlf)*4], valx, xpam); | ||||
add4ucf(&bkgrd_data[(bkgrd_width*hlf + wlfn)*4], valx, xpa); | ||||
add4ucf(&bkgrd_data[(bkgrd_width*hlfn + wlf)*4], valy, xpam); | ||||
add4ucf(&bkgrd_data[(bkgrd_width*hlfn + wlfn)*4], valy, xpa); | ||||
mult4f(valx, ypam, val); | ||||
mult4f(valy, ypa, valy); | ||||
add4f(valy, val, val); | ||||
copy4fuc(val, bkrd); | ||||
} else { | ||||
copy4f(&bkgrd_data[(bkgrd_width*(int)floor(hl) + (int)floor(wl))*4], bkrd); | ||||
} | ||||
// alpha blending with bg_rgb if needed | ||||
if (blend_bg && bkrd[3] < 255){ | ||||
float alpha = (255.f - bkrd[3]) / 255.f; | ||||
float tmpadd1[3], tmpadd2[3]; | ||||
tmpadd1[0] = bkrd[0]; tmpadd1[1] = bkrd[1]; tmpadd1[2] = bkrd[2]; | ||||
mult3f(tmpadd1, 1.f - alpha, tmpadd1); | ||||
mult3f(bg_rgb, alpha, tmpadd2); | ||||
add3f(tmpadd1, tmpadd2, tmpadd2); | ||||
bkrd[0] = 0xFF & (int)pymol_roundf(tmpadd2[0]); | ||||
bkrd[1] = 0xFF & (int)pymol_roundf(tmpadd2[1]); | ||||
bkrd[2] = 0xFF & (int)pymol_roundf(tmpadd2[2]); | ||||
bkrd[3] = 255; | ||||
} | ||||
} | ||||
static void fill_background_image(CRay * I, unsigned int *buffer, int width, int | ||||
height, unsigned int cnt){ | ||||
int bkgrd_width = I->bkgrd_width, bkgrd_height = I->bkgrd_height; | ||||
unsigned char *bkgrd_data = I->bkgrd_data; | ||||
int bg_image_mode = SettingGetGlobal_i(I->G, cSetting_bg_image_mode); | ||||
int bg_image_linear = SettingGetGlobal_b(I->G, cSetting_bg_image_linear); | ||||
float bg_rgb[3]; | ||||
const float *tmpf; | ||||
int w, h; | ||||
unsigned int value; | ||||
float wr = bkgrd_width/(float)width, hr = bkgrd_height/(float)height; | ||||
float hl; | ||||
unsigned int back_mask; | ||||
unsigned char bkrd[4]; | ||||
float hpixelx = floor(width/2.f) - floor(bkgrd_width / 2.f), | ||||
hpixely = floor(height/2.f) - floor(bkgrd_height / 2.f); | ||||
auto bg_image_tilesize = SettingGet<const float*>(I->G, cSetting_bg_image_tile | ||||
size); | ||||
short isOutsideInY = 0; | ||||
int opaque_back ; | ||||
opaque_back = SettingGetGlobal_i(I->G, cSetting_ray_opaque_background); | ||||
if(opaque_back < 0) | ||||
opaque_back = SettingGetGlobal_i(I->G, cSetting_opaque_background); | ||||
tmpf = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb)); | ||||
mult3f(tmpf, 255.f, bg_rgb); | ||||
if(opaque_back) { | ||||
if(I->BigEndian) | ||||
back_mask = 0x000000FF; | ||||
else | ||||
back_mask = 0xFF000000; | ||||
} else { | ||||
back_mask = 0x00000000; | ||||
} | ||||
// tiled or stretched | ||||
for (h=0; h<height; h++){ | ||||
switch (bg_image_mode){ | ||||
case 1: // isCentered | ||||
{ | ||||
float tmpy = floor(h - hpixely); | ||||
isOutsideInY = (tmpy < 0.f || tmpy > (float)bkgrd_height); | ||||
hl = fmodpos(tmpy, (float)bkgrd_height); | ||||
} | ||||
break; | ||||
case 2: // isTiled | ||||
hl = bkgrd_height * (fmodpos((float)h, bg_image_tilesize[1])/bg_image_tile | ||||
size[1]); | ||||
break; | ||||
case 3: // isCenteredRepeated | ||||
hl = fmodpos(floor(h - hpixely), (float)bkgrd_height); | ||||
break; | ||||
default: | ||||
hl = h * hr; | ||||
break; | ||||
} | ||||
for (w=0; w<width; w++){ | ||||
compute_background_for_pixel(bkrd, isOutsideInY, bg_image_mode, bg_image_t | ||||
ilesize, bg_rgb, bg_image_linear, bkgrd_data, bkgrd_width, bkgrd_height, w, wr, | ||||
hl, hpixelx, opaque_back ); | ||||
if(I->BigEndian){ | ||||
value = | ||||
((0xFF & bkrd[0]) << 24) | | ||||
((0xFF & bkrd[1]) << 16) | | ||||
((0xFF & bkrd[2]) << 8) | | ||||
(0xFF & bkrd[3]); | ||||
} else { | ||||
value = | ||||
((0xFF & bkrd[3]) << 24) | | ||||
((0xFF & bkrd[2]) << 16) | | ||||
((0xFF & bkrd[1]) << 8) | | ||||
(0xFF & bkrd[0]); | ||||
} | ||||
if(opaque_back) { | ||||
value = back_mask | value; | ||||
} | ||||
*(buffer++) = value; | ||||
} | ||||
} | ||||
} | ||||
static void fill_gradient(CRay * I, int opaque_back, unsigned int *buffer, float *bkrd_bottom, float *bkrd_top, int width, int height, unsigned int cnt) | static void fill_gradient(CRay * I, int opaque_back, unsigned int *buffer, float *bkrd_bottom, float *bkrd_top, int width, int height, unsigned int cnt) | |||
{ | { | |||
const float _p499 = 0.499F; | const float _p499 = 0.499F; | |||
int w, h; | int w, h; | |||
unsigned int value; | unsigned int value; | |||
float bkrd[3], perc; | float bkrd[3], perc; | |||
unsigned int back_mask; | unsigned int back_mask; | |||
if(opaque_back) { | if(opaque_back) { | |||
if(I->BigEndian) | if(I->BigEndian) | |||
skipping to change at line 662 | skipping to change at line 827 | |||
minmax(v, r); | minmax(v, r); | |||
v = basis1->Normal + basis1->Vert2Normal[prm->vert] * 3; | v = basis1->Normal + basis1->Vert2Normal[prm->vert] * 3; | |||
scale3f(v, prm->l1, vt); | scale3f(v, prm->l1, vt); | |||
v = basis1->Vertex + prm->vert * 3; | v = basis1->Vertex + prm->vert * 3; | |||
add3f(v, vt, vt); | add3f(v, vt, vt); | |||
minmax(vt, r); | minmax(vt, r); | |||
break; | break; | |||
} /* end of switch */ | } /* end of switch */ | |||
} | } | |||
} | } | |||
I->min_box[0] = xmin; | // without the R_SMALL4 padding, this caused ray tracing failure | |||
I->min_box[1] = ymin; | // on OS X (X11) with a flat ObjectCGO (zmin == zmax). | |||
I->min_box[2] = zmin; | I->min_box[0] = xmin - R_SMALL4; | |||
I->max_box[0] = xmax; | I->min_box[1] = ymin - R_SMALL4; | |||
I->max_box[1] = ymax; | I->min_box[2] = zmin - R_SMALL4; | |||
I->max_box[2] = zmax; | I->max_box[0] = xmax + R_SMALL4; | |||
I->max_box[1] = ymax + R_SMALL4; | ||||
I->max_box[2] = zmax + R_SMALL4; | ||||
} | } | |||
int RayTransformFirst(CRay * I, int perspective, int identity) | int RayTransformFirst(CRay * I, int perspective, int identity) | |||
{ | { | |||
CBasis *basis0, *basis1; | CBasis *basis0, *basis1; | |||
CPrimitive *prm; | CPrimitive *prm; | |||
int a; | int a; | |||
float *v0; | float *v0; | |||
int backface_cull; | int backface_cull; | |||
int ok = true; | int ok = true; | |||
skipping to change at line 2370 | skipping to change at line 2537 | |||
*objVLA_ptr = objVLA; | *objVLA_ptr = objVLA; | |||
*mtlVLA_ptr = mtlVLA; | *mtlVLA_ptr = mtlVLA; | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void RayRenderPOV(CRay * I, int width, int height, char **headerVLA_ptr, | void RayRenderPOV(CRay * I, int width, int height, char **headerVLA_ptr, | |||
char **charVLA_ptr, float front, float back, float fov, | char **charVLA_ptr, float front, float back, float fov, | |||
float angle, int antialias) | float angle, int antialias) | |||
{ | { | |||
float fog; | float fog; | |||
float *bkrd; | const float *bkrd; | |||
float fog_start = 0.0F; | float fog_start = 0.0F; | |||
float gamma; | float gamma; | |||
float *d; | float *d; | |||
CBasis *base; | CBasis *base; | |||
CPrimitive *prim; | CPrimitive *prim; | |||
OrthoLineType buffer; | OrthoLineType buffer; | |||
float *vert, *norm; | float *vert, *norm; | |||
float vert2[3]; | float vert2[3]; | |||
ov_size cc, hc; | ov_size cc, hc; | |||
int a; | int a; | |||
skipping to change at line 2547 | skipping to change at line 2714 | |||
if(opaque_back) { /* drop a plane into the background for the back ground color */ | if(opaque_back) { /* drop a plane into the background for the back ground color */ | |||
sprintf(buffer, | sprintf(buffer, | |||
"plane{z , %6.4f \n pigment{color rgb<%6.4f,%6.4f,%6.4f>}\n finish {phong 0 specular 0 diffuse 0 ambient 1.0}}\n", | "plane{z , %6.4f \n pigment{color rgb<%6.4f,%6.4f,%6.4f>}\n finish {phong 0 specular 0 diffuse 0 ambient 1.0}}\n", | |||
-back, bkrd[0], bkrd[1], bkrd[2]); | -back, bkrd[0], bkrd[1], bkrd[2]); | |||
UtilConcatVLA(&headerVLA, &hc, buffer); | UtilConcatVLA(&headerVLA, &hc, buffer); | |||
} | } | |||
} | } | |||
for(a = 0; a < I->NPrimitive; a++) { | for(a = 0; a < I->NPrimitive; a++) { | |||
char cap1 = cCylCapRound; | ||||
char cap2 = cCylCapRound; | ||||
prim = I->Primitive + a; | prim = I->Primitive + a; | |||
vert = base->Vertex + 3 * (prim->vert); | vert = base->Vertex + 3 * (prim->vert); | |||
if(prim->type == cPrimTriangle) { | if(prim->type == cPrimTriangle) { | |||
if(smooth_color_triangle) | if(smooth_color_triangle) | |||
if(!mesh_obj) { | if(!mesh_obj) { | |||
sprintf(buffer, "mesh {\n"); | sprintf(buffer, "mesh {\n"); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
mesh_obj = true; | mesh_obj = true; | |||
} | } | |||
} else if(mesh_obj) { | } else if(mesh_obj) { | |||
skipping to change at line 2571 | skipping to change at line 2740 | |||
switch (prim->type) { | switch (prim->type) { | |||
case cPrimSphere: | case cPrimSphere: | |||
sprintf(buffer, "sphere{<%12.10f,%12.10f,%12.10f>, %12.10f\n", | sprintf(buffer, "sphere{<%12.10f,%12.10f,%12.10f>, %12.10f\n", | |||
vert[0], vert[1], vert[2], prim->r1); | vert[0], vert[1], vert[2], prim->r1); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
sprintf(buffer, "pigment{color rgb<%6.4f,%6.4f,%6.4f>}}\n", | sprintf(buffer, "pigment{color rgb<%6.4f,%6.4f,%6.4f>}}\n", | |||
prim->c1[0], prim->c1[1], prim->c1[2]); | prim->c1[0], prim->c1[1], prim->c1[2]); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
break; | break; | |||
case cPrimCylinder: | case cPrimCylinder: | |||
d = base->Normal + 3 * base->Vert2Normal[prim->vert]; | cap1 = prim->cap1; | |||
scale3f(d, prim->l1, vert2); | cap2 = prim->cap2; | |||
add3f(vert, vert2, vert2); | ||||
sprintf(buffer, | ||||
"cylinder{<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12.10f,%12.10f>,\n | ||||
%12.10f\n", | ||||
vert[0], vert[1], vert[2], vert2[0], vert2[1], vert2[2], prim->r1) | ||||
; | ||||
UtilConcatVLA(&charVLA, &cc, buffer); | ||||
sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | ||||
(prim->c1[0] + prim->c2[0]) / 2, | ||||
(prim->c1[1] + prim->c2[1]) / 2, (prim->c1[2] + prim->c2[2]) / 2); | ||||
UtilConcatVLA(&charVLA, &cc, buffer); | ||||
break; | ||||
case cPrimSausage: | case cPrimSausage: | |||
d = base->Normal + 3 * base->Vert2Normal[prim->vert]; | d = base->Normal + 3 * base->Vert2Normal[prim->vert]; | |||
scale3f(d, prim->l1, vert2); | scale3f(d, prim->l1, vert2); | |||
add3f(vert, vert2, vert2); | add3f(vert, vert2, vert2); | |||
sprintf(buffer, | sprintf(buffer, | |||
"cylinder{<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12.10f,%12.10f>,\n %12.10f\nopen\n", | "cylinder{<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12.10f,%12.10f>,\n %12.10f\n", | |||
vert[0], vert[1], vert[2], vert2[0], vert2[1], vert2[2], prim->r1) ; | vert[0], vert[1], vert[2], vert2[0], vert2[1], vert2[2], prim->r1) ; | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
if (cap1 != cCylCapFlat && cap2 != cCylCapFlat) { | ||||
UtilConcatVLA(&charVLA, &cc, "open\n"); | ||||
} | ||||
sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | |||
(prim->c1[0] + prim->c2[0]) / 2, | (prim->c1[0] + prim->c2[0]) / 2, | |||
(prim->c1[1] + prim->c2[1]) / 2, (prim->c1[2] + prim->c2[2]) / 2); | (prim->c1[1] + prim->c2[1]) / 2, (prim->c1[2] + prim->c2[2]) / 2); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
if (cap1 == cCylCapRound) { | ||||
sprintf(buffer, "sphere{<%12.10f,%12.10f,%12.10f>, %12.10f\n", | sprintf(buffer, "sphere{<%12.10f,%12.10f,%12.10f>, %12.10f\n", | |||
vert[0], vert[1], vert[2], prim->r1); | vert[0], vert[1], vert[2], prim->r1); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | |||
prim->c1[0], prim->c1[1], prim->c1[2]); | prim->c1[0], prim->c1[1], prim->c1[2]); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
} | ||||
if (cap2 == cCylCapRound) { | ||||
sprintf(buffer, "sphere{<%12.10f,%12.10f,%12.10f>, %12.10f\n", | sprintf(buffer, "sphere{<%12.10f,%12.10f,%12.10f>, %12.10f\n", | |||
vert2[0], vert2[1], vert2[2], prim->r1); | vert2[0], vert2[1], vert2[2], prim->r1); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | sprintf(buffer, "pigment{color rgb<%6.4f1,%6.4f,%6.4f>}}\n", | |||
prim->c2[0], prim->c2[1], prim->c2[2]); | prim->c2[0], prim->c2[1], prim->c2[2]); | |||
UtilConcatVLA(&charVLA, &cc, buffer); | UtilConcatVLA(&charVLA, &cc, buffer); | |||
} | ||||
break; | break; | |||
case cPrimTriangle: | case cPrimTriangle: | |||
norm = base->Normal + 3 * base->Vert2Normal[prim->vert] + 3; /* first normal is the average */ | norm = base->Normal + 3 * base->Vert2Normal[prim->vert] + 3; /* first normal is the average */ | |||
if(!TriangleDegenerate(vert, norm, vert + 3, norm + 3, vert + 6, norm + 6) ) { | if(!TriangleDegenerate(vert, norm, vert + 3, norm + 3, vert + 6, norm + 6) ) { | |||
if(smooth_color_triangle) { | if(smooth_color_triangle) { | |||
sprintf(buffer, | sprintf(buffer, | |||
"smooth_color_triangle{<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%1 2.10f,%12.10f>,\n<%6.4f1,%6.4f,%6.4f>,\n<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12 .10f,%12.10f>,\n<%6.4f1,%6.4f,%6.4f>,\n<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12. 10f,%12.10f>,\n<%6.4f1,%6.4f,%6.4f> }\n", | "smooth_color_triangle{<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%1 2.10f,%12.10f>,\n<%6.4f1,%6.4f,%6.4f>,\n<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12 .10f,%12.10f>,\n<%6.4f1,%6.4f,%6.4f>,\n<%12.10f,%12.10f,%12.10f>,\n<%12.10f,%12. 10f,%12.10f>,\n<%6.4f1,%6.4f,%6.4f> }\n", | |||
skipping to change at line 2779 | skipping to change at line 2947 | |||
} | } | |||
#endif | #endif | |||
int RayHashThread(CRayHashThreadInfo * T) | int RayHashThread(CRayHashThreadInfo * T) | |||
{ | { | |||
BasisMakeMap(T->basis, T->vert2prim, T->prim, T->n_prim, T->clipBox, T->phase, | BasisMakeMap(T->basis, T->vert2prim, T->prim, T->n_prim, T->clipBox, T->phase, | |||
cCache_ray_map, T->perspective, T->front, T->size_hint); | cCache_ray_map, T->perspective, T->front, T->size_hint); | |||
/* utilize a little extra wasted CPU time in thread 0 which computes the small er map... */ | /* utilize a little extra wasted CPU time in thread 0 which computes the small er map... */ | |||
if(!T->phase) { | if(!T->phase) { | |||
if (T->bkrd_is_gradient){ | if (T->ray->bkgrd_data){ | |||
fill_background_image(T->ray, T->image, T->width, T->height, T->width * ( | ||||
unsigned int) T->height); | ||||
} else if (T->bkrd_is_gradient){ | ||||
fill_gradient(T->ray, T->opaque_back, T->image, T->bkrd_top, T->bkrd_botto m, T->width, T->height, T->width * (unsigned int) T->height); | fill_gradient(T->ray, T->opaque_back, T->image, T->bkrd_top, T->bkrd_botto m, T->width, T->height, T->width * (unsigned int) T->height); | |||
} else { | } else { | |||
fill(T->image, T->background, T->bytes); | fill(T->image, T->background, T->bytes); | |||
} | } | |||
RayComputeBox(T->ray); | RayComputeBox(T->ray); | |||
} | } | |||
return 1; | return 1; | |||
} | } | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
skipping to change at line 3101 | skipping to change at line 3271 | |||
const float _0 = 0.0F; | const float _0 = 0.0F; | |||
const float _1 = 1.0F; | const float _1 = 1.0F; | |||
const float _p5 = 0.5F; | const float _p5 = 0.5F; | |||
const float _2 = 2.0F; | const float _2 = 2.0F; | |||
const float _255 = 255.0F; | const float _255 = 255.0F; | |||
const float _p499 = 0.499F; | const float _p499 = 0.499F; | |||
const float _persistLimit = 0.0001F; | const float _persistLimit = 0.0001F; | |||
float legacy_1m = _1 - legacy; | float legacy_1m = _1 - legacy; | |||
int n_basis = I->NBasis; | int n_basis = I->NBasis; | |||
unsigned int back_mask; | unsigned int back_mask; | |||
float bg_rgb[3], *tmpf; | int bg_image_mode = SettingGetGlobal_i(I->G, cSetting_bg_image_mode); | |||
int bg_image_linear = SettingGetGlobal_b(I->G, cSetting_bg_image_linear); | ||||
auto bg_image_tilesize = SettingGet<const float*>(I->G, cSetting_bg_image_tile | ||||
size); | ||||
float hpixelx = floor(T->width/2.f) - floor(T->bgWidth / 2.f), | ||||
hpixely = floor(T->height/2.f) - floor(T->bgHeight / 2.f); | ||||
float hl; | ||||
float wr = T->bgWidth/(float)T->width, hr = T->bgHeight/(float)T->height; | ||||
float bg_rgb[3]; | ||||
const float *tmpf; | ||||
int chromadepth; | ||||
tmpf = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb)); | tmpf = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb)); | |||
mult3f(tmpf, 255.f, bg_rgb); | mult3f(tmpf, 255.f, bg_rgb); | |||
/* MemoryDebugDump(); | /* MemoryDebugDump(); | |||
printf("%d\n",sizeof(CPrimitive)); | printf("%d\n",sizeof(CPrimitive)); | |||
*/ | */ | |||
{ | { | |||
float fudge = SettingGetGlobal_f(I->G, cSetting_ray_triangle_fudge); | float fudge = SettingGetGlobal_f(I->G, cSetting_ray_triangle_fudge); | |||
skipping to change at line 3140 | skipping to change at line 3320 | |||
project_triangle = SettingGetGlobal_f(I->G, cSetting_ray_improve_shadows); | project_triangle = SettingGetGlobal_f(I->G, cSetting_ray_improve_shadows); | |||
shadows = SettingGetGlobal_i(I->G, cSetting_ray_shadows); | shadows = SettingGetGlobal_i(I->G, cSetting_ray_shadows); | |||
trans_shadows = SettingGetGlobal_i(I->G, cSetting_ray_transparency_shadows); | trans_shadows = SettingGetGlobal_i(I->G, cSetting_ray_transparency_shadows); | |||
backface_cull = SettingGetGlobal_i(I->G, cSetting_backface_cull); | backface_cull = SettingGetGlobal_i(I->G, cSetting_backface_cull); | |||
opaque_back = SettingGetGlobal_i(I->G, cSetting_ray_opaque_background); | opaque_back = SettingGetGlobal_i(I->G, cSetting_ray_opaque_background); | |||
if(opaque_back < 0) | if(opaque_back < 0) | |||
opaque_back = SettingGetGlobal_i(I->G, cSetting_opaque_background); | opaque_back = SettingGetGlobal_i(I->G, cSetting_opaque_background); | |||
orig_opaque_back = opaque_back; | orig_opaque_back = opaque_back; | |||
if (T->bkrd_data){ | ||||
opaque_back = 1; | ||||
} | ||||
two_sided_lighting = SettingGetGlobal_i(I->G, cSetting_two_sided_lighting); | two_sided_lighting = SettingGetGlobal_i(I->G, cSetting_two_sided_lighting); | |||
if(two_sided_lighting<0) { | if(two_sided_lighting<0) { | |||
if(SettingGetGlobal_i(I->G, cSetting_surface_cavity_mode)) | if(SettingGetGlobal_i(I->G, cSetting_surface_cavity_mode)) | |||
two_sided_lighting = true; | two_sided_lighting = true; | |||
else | else | |||
two_sided_lighting = false; | two_sided_lighting = false; | |||
} | } | |||
ray_trans_spec = SettingGetGlobal_f(I->G, cSetting_ray_transparency_specular); | ray_trans_spec = SettingGetGlobal_f(I->G, cSetting_ray_transparency_specular); | |||
ray_lab_spec = SettingGetGlobal_f(I->G, cSetting_ray_label_specular); | ray_lab_spec = SettingGetGlobal_f(I->G, cSetting_ray_label_specular); | |||
trans_cont = SettingGetGlobal_f(I->G, cSetting_ray_transparency_contrast); | trans_cont = SettingGetGlobal_f(I->G, cSetting_ray_transparency_contrast); | |||
trans_mode = SettingGetGlobal_i(I->G, cSetting_transparency_mode); | trans_mode = SettingGetGlobal_i(I->G, cSetting_transparency_mode); | |||
trans_oblique = SettingGetGlobal_f(I->G, cSetting_ray_transparency_oblique); | trans_oblique = SettingGetGlobal_f(I->G, cSetting_ray_transparency_oblique); | |||
oblique_power = SettingGetGlobal_f(I->G, cSetting_ray_transparency_oblique_pow er); | oblique_power = SettingGetGlobal_f(I->G, cSetting_ray_transparency_oblique_pow er); | |||
trans_cutoff = SettingGetGlobal_f(I->G, cSetting_ray_trace_trans_cutoff); | trans_cutoff = SettingGetGlobal_f(I->G, cSetting_ray_trace_trans_cutoff); | |||
persist_cutoff = SettingGetGlobal_f(I->G, cSetting_ray_trace_persist_cutoff); | persist_cutoff = SettingGetGlobal_f(I->G, cSetting_ray_trace_persist_cutoff); | |||
chromadepth = SettingGetGlobal_i(I->G, cSetting_chromadepth); | ||||
if(trans_mode == 1) | if(trans_mode == 1) | |||
two_sided_lighting = true; | two_sided_lighting = true; | |||
if(trans_cont > 1.0F) { | if(trans_cont > 1.0F) { | |||
trans_cont_flag = true; | trans_cont_flag = true; | |||
inv_trans_cont = 1.0F / trans_cont; | inv_trans_cont = 1.0F / trans_cont; | |||
} | } | |||
ambient = T->ambient; | ambient = T->ambient; | |||
/* divide up the reflected light component over all lights */ | /* divide up the reflected light component over all lights */ | |||
{ | { | |||
skipping to change at line 3198 | skipping to change at line 3383 | |||
} | } | |||
if(trans_spec_cut < _1) | if(trans_spec_cut < _1) | |||
trans_spec_scale = _1 / (_1 - trans_spec_cut); | trans_spec_scale = _1 / (_1 - trans_spec_cut); | |||
else | else | |||
trans_spec_scale = _0; | trans_spec_scale = _0; | |||
/* COOP */ | /* COOP */ | |||
settingPower = SettingGetGlobal_f(I->G, cSetting_power); | settingPower = SettingGetGlobal_f(I->G, cSetting_power); | |||
settingReflectPower = SettingGetGlobal_f(I->G, cSetting_reflect_power); | settingReflectPower = SettingGetGlobal_f(I->G, cSetting_reflect_power); | |||
settingSpecPower = SettingGetGlobal_f(I->G, cSetting_spec_power); | ||||
if(settingSpecPower < 0.0F) { | ||||
settingSpecPower = SettingGetGlobal_f(I->G, cSetting_shininess); | ||||
} | ||||
{ | SceneGetAdjustedLightValues(I->G, | |||
float spec_value = SettingGetGlobal_f(I->G, cSetting_specular); | &settingSpecReflect, | |||
if(spec_value == 1.0F) | &settingSpecPower, | |||
spec_value = SettingGetGlobal_f(I->G, cSetting_specular_intensity); | &settingSpecDirect, | |||
settingSpecReflect = SettingGetGlobal_f(I->G, cSetting_spec_reflect); | &settingSpecDirectPower, 10); | |||
if(settingSpecReflect < 0.0F) | ||||
settingSpecReflect = spec_value; | ||||
settingSpecReflect = SceneGetSpecularValue(I->G, settingSpecReflect, 10); | ||||
settingSpecDirect = SettingGetGlobal_f(I->G, cSetting_spec_direct); | ||||
if(settingSpecDirect < 0.0F) | ||||
settingSpecDirect = spec_value; | ||||
settingSpecDirectPower = SettingGetGlobal_f(I->G, cSetting_spec_direct_power | ||||
); | ||||
if(settingSpecDirectPower < 0.0F) | ||||
settingSpecDirectPower = settingSpecPower; | ||||
} | ||||
if(settingSpecReflect > 1.0F) | ||||
settingSpecReflect = 1.0F; | ||||
if(SettingGetGlobal_f(I->G, cSetting_specular) < R_SMALL4) { | ||||
settingSpecReflect = 0.0F; | ||||
} | ||||
if((interior_color != -1) || (two_sided_lighting) || (trans_mode == 1) | if((interior_color != -1) || (two_sided_lighting) || (trans_mode == 1) | |||
|| I->CheckInterior) | || I->CheckInterior) | |||
backface_cull = 0; | backface_cull = 0; | |||
shadow_fudge = SettingGetGlobal_f(I->G, cSetting_ray_shadow_fudge); | shadow_fudge = SettingGetGlobal_f(I->G, cSetting_ray_shadow_fudge); | |||
inv1minusFogStart = _1; | inv1minusFogStart = _1; | |||
fog = SettingGetGlobal_f(I->G, cSetting_ray_trace_fog); | fog = SettingGetGlobal_f(I->G, cSetting_ray_trace_fog); | |||
skipping to change at line 3375 | skipping to change at line 3541 | |||
back_mask = 0x000000FF; | back_mask = 0x000000FF; | |||
else | else | |||
back_mask = 0xFF000000; | back_mask = 0xFF000000; | |||
} else { | } else { | |||
back_mask = 0x00000000; | back_mask = 0x00000000; | |||
} | } | |||
} | } | |||
for(yy = T->y_start; (yy < T->y_stop); yy++) { | for(yy = T->y_start; (yy < T->y_stop); yy++) { | |||
float perc, bkrd[4]; | float perc, bkrd[4]; | |||
unsigned int bkrd_value; | unsigned int bkrd_value; | |||
short isOutsideInY = 0; | ||||
if(I->G->Interrupt) | if(I->G->Interrupt) | |||
break; | break; | |||
y = T->y_start + ((yy - T->y_start) + offset) % (render_height); /* make sure threads write to different pages */ | y = T->y_start + ((yy - T->y_start) + offset) % (render_height); /* make sure threads write to different pages */ | |||
if (T->bkrd_is_gradient){ | if (T->bkrd_data){ | |||
switch (bg_image_mode){ | ||||
case 1: // isCentered | ||||
{ | ||||
float tmpy = floor(y - hpixely); | ||||
isOutsideInY = (tmpy < 0.f || tmpy > (float)T->bgHeight); | ||||
hl = fmodpos(tmpy, (float)T->bgHeight); | ||||
} | ||||
break; | ||||
case 2: // isTiled | ||||
hl = (float)T->bgHeight * (fmodpos((float)y, bg_image_tilesize[1])/bg_ima | ||||
ge_tilesize[1]); | ||||
break; | ||||
case 3: // isCenteredRepeated | ||||
hl = fmodpos(floor(y - hpixely), (float)T->bgHeight); | ||||
break; | ||||
default: | ||||
hl = y * hr; | ||||
break; | ||||
} | ||||
} else if (T->bkrd_is_gradient){ | ||||
/* for RayTraceThread, y is from bottom to top */ | /* for RayTraceThread, y is from bottom to top */ | |||
perc = y/(float)T->height; | perc = y/(float)T->height; | |||
bkrd[0] = T->bkrd_bottom[0] + perc * (T->bkrd_top[0] - T->bkrd_bottom[0]); | bkrd[0] = T->bkrd_bottom[0] + perc * (T->bkrd_top[0] - T->bkrd_bottom[0]); | |||
bkrd[1] = T->bkrd_bottom[1] + perc * (T->bkrd_top[1] - T->bkrd_bottom[1]); | bkrd[1] = T->bkrd_bottom[1] + perc * (T->bkrd_top[1] - T->bkrd_bottom[1]); | |||
bkrd[2] = T->bkrd_bottom[2] + perc * (T->bkrd_top[2] - T->bkrd_bottom[2]); | bkrd[2] = T->bkrd_bottom[2] + perc * (T->bkrd_top[2] - T->bkrd_bottom[2]); | |||
bkrd[3] = 1.f; | bkrd[3] = 1.f; | |||
if(T->ray->BigEndian){ | if(T->ray->BigEndian){ | |||
bkrd_value = back_mask | | bkrd_value = back_mask | | |||
((0xFF & ((unsigned int) (bkrd[0] * 255 + _p499))) << 24) | | ((0xFF & ((unsigned int) (bkrd[0] * 255 + _p499))) << 24) | | |||
((0xFF & ((unsigned int) (bkrd[1] * 255 + _p499))) << 16) | | ((0xFF & ((unsigned int) (bkrd[1] * 255 + _p499))) << 16) | | |||
skipping to change at line 3426 | skipping to change at line 3612 | |||
} else { | } else { | |||
OrthoBusyFast(I->G, T->height / 3 + y, 4 * T->height / 3); | OrthoBusyFast(I->G, T->height / 3 + y, 4 * T->height / 3); | |||
} | } | |||
} | } | |||
pixel = T->image + (T->width * y) + T->x_start; | pixel = T->image + (T->width * y) + T->x_start; | |||
if((y % T->n_thread) == T->phase) { /* this is my scan line */ | if((y % T->n_thread) == T->phase) { /* this is my scan line */ | |||
pixel_base[1] = ((y + 0.5F + border_offset) * invHgtRange) + vol2; | pixel_base[1] = ((y + 0.5F + border_offset) * invHgtRange) + vol2; | |||
for(x = T->x_start; (x < T->x_stop); x++) { | for(x = T->x_start; (x < T->x_stop); x++) { | |||
if (T->bkrd_data){ | ||||
// Need to compute background for every pixel if image-based | ||||
unsigned char bkrd_uc[4]; | ||||
compute_background_for_pixel(bkrd_uc, isOutsideInY, | ||||
bg_image_mode, bg_image_tilesize, bg_rgb, bg_image_linear, | ||||
(unsigned char*) T->bkrd_data, T->bgWidth, T->bgHeight, | ||||
x, wr, hl, hpixelx, orig_opaque_back ); | ||||
bkrd[0] = bkrd_uc[0] / 255.f; | ||||
bkrd[1] = bkrd_uc[1] / 255.f; | ||||
bkrd[2] = bkrd_uc[2] / 255.f; | ||||
bkrd[3] = bkrd_uc[3] / 255.f; | ||||
if(T->ray->BigEndian){ | ||||
bkrd_value = back_mask | | ||||
((0xFF & ((unsigned int) (bkrd_uc[0] * 255 + _p499))) << 24) | | ||||
((0xFF & ((unsigned int) (bkrd_uc[1] * 255 + _p499))) << 16) | | ||||
((0xFF & ((unsigned int) (bkrd_uc[2] * 255 + _p499))) << 8); | ||||
} else { | ||||
bkrd_value = back_mask | | ||||
((0xFF & ((unsigned int) (bkrd_uc[2] * 255 + _p499))) << 16) | | ||||
((0xFF & ((unsigned int) (bkrd_uc[1] * 255 + _p499))) << 8) | | ||||
((0xFF & ((unsigned int) (bkrd_uc[0] * 255 + _p499)))); | ||||
} | ||||
} | ||||
pixel_base[0] = (((x + 0.5F + border_offset)) * invWdthRange) + vol0; | pixel_base[0] = (((x + 0.5F + border_offset)) * invWdthRange) + vol0; | |||
while(1) { | while(1) { | |||
if(T->edging) { | if(T->edging) { | |||
if(!edge_sampling) { | if(!edge_sampling) { | |||
if(x && y && (x < (T->width - 1)) && (y < (T->height - 1))) { /* not on the edge... */ | if(x && y && (x < (T->width - 1)) && (y < (T->height - 1))) { /* not on the edge... */ | |||
if(find_edge(T->edging + (pixel - T->image), | if(find_edge(T->edging + (pixel - T->image), | |||
depth + (pixel - T->image), | depth + (pixel - T->image), | |||
T->width, T->edging_cutoff, bkrd_value)) { | T->width, T->edging_cutoff, bkrd_value)) { | |||
unsigned char *pixel_c = (unsigned char *) pixel; | unsigned char *pixel_c = (unsigned char *) pixel; | |||
skipping to change at line 3555 | skipping to change at line 3765 | |||
normalize3f(r1.dir); | normalize3f(r1.dir); | |||
{ | { | |||
float scale = I->max_box[2] / r1.base[2]; | float scale = I->max_box[2] / r1.base[2]; | |||
r1.skip[0] = r1.base[0] * scale; | r1.skip[0] = r1.base[0] * scale; | |||
r1.skip[1] = r1.base[1] * scale; | r1.skip[1] = r1.base[1] * scale; | |||
r1.skip[2] = I->max_box[2]; | r1.skip[2] = I->max_box[2]; | |||
} | } | |||
} | } | |||
while((persist > _persistLimit) && (pass <= max_pass)) { | while((persist > _persistLimit) && (pass <= max_pass)) { | |||
char fogFlagTmp = fogFlag; | ||||
pixel_flag = false; | pixel_flag = false; | |||
BasisCall[0].except1 = exclude1; | BasisCall[0].except1 = exclude1; | |||
BasisCall[0].except2 = exclude2; | BasisCall[0].except2 = exclude2; | |||
BasisCall[0].front = new_front; | BasisCall[0].front = new_front; | |||
BasisCall[0].excl_trans = excl_trans; | BasisCall[0].excl_trans = excl_trans; | |||
BasisCall[0].interior_flag = false; | BasisCall[0].interior_flag = false; | |||
BasisCall[0].pass = pass; | BasisCall[0].pass = pass; | |||
if(perspective) { | if(perspective) { | |||
if(pass) { | if(pass) { | |||
add3f(nudge, r1.base, r1.base); | add3f(nudge, r1.base, r1.base); | |||
copy3f(r1.base, r1.skip); | copy3f(r1.base, r1.skip); | |||
} | } | |||
BasisCall[0].back_dist = -(T->back + r1.base[2]) / r1.dir[2]; | BasisCall[0].back_dist = -(T->back + r1.base[2]) / r1.dir[2]; | |||
i = BasisHitPerspective(&BasisCall[0]); | i = BasisHitPerspective(&BasisCall[0]); | |||
} else { | } else { | |||
i = BasisHitOrthoscopic(&BasisCall[0]); | i = BasisHitOrthoscopic(&BasisCall[0]); | |||
} | } | |||
interior_flag = BasisCall[0].interior_flag && (!pass); | interior_flag = BasisCall[0].interior_flag && (!pass); | |||
if(((i >= 0) || interior_flag) && (pass < max_pass)) { | if(((i >= 0) || interior_flag) && (pass < max_pass)) { | |||
int n_basis_tmp = r1.prim->no_lighting ? 0 : n_basis; | ||||
pixel_flag = true; | pixel_flag = true; | |||
n_hit++; | n_hit++; | |||
if(((r1.trans = r1.prim->trans) != _0) && trans_cont_flag) { | if(((r1.trans = r1.prim->trans) != _0) && trans_cont_flag) { | |||
r1.trans = (float) pow(r1.trans, inv_trans_cont); | r1.trans = (float) pow(r1.trans, inv_trans_cont); | |||
} | } | |||
if(interior_flag) { | if(interior_flag) { | |||
copy3f(interior_normal, r1.surfnormal); | copy3f(interior_normal, r1.surfnormal); | |||
if(perspective) { | if(perspective) { | |||
copy3f(start, r1.impact); | copy3f(start, r1.impact); | |||
r1.dist = _0; | r1.dist = _0; | |||
skipping to change at line 3642 | skipping to change at line 3852 | |||
if(perspective) { | if(perspective) { | |||
BasisGetTriangleFlatDotglePerspective(bp1, &r1, i); | BasisGetTriangleFlatDotglePerspective(bp1, &r1, i); | |||
} else { | } else { | |||
BasisGetTriangleFlatDotgle(bp1, &r1, i); | BasisGetTriangleFlatDotgle(bp1, &r1, i); | |||
} | } | |||
break; | break; | |||
case cPrimCharacter: | case cPrimCharacter: | |||
BasisGetTriangleNormal(bp1, &r1, i, fc, perspective); | BasisGetTriangleNormal(bp1, &r1, i, fc, perspective); | |||
r1.trans = CharacterInterpolate(I->G, r1.prim->char_id, fc); | r1.trans = CharacterInterpolate(I->G, r1.prim->char_id, fc); | |||
fogFlagTmp = false; | ||||
RayReflectAndTexture(I, &r1, perspective); | RayReflectAndTexture(I, &r1, perspective); | |||
BasisGetTriangleFlatDotgle(bp1, &r1, i); | BasisGetTriangleFlatDotgle(bp1, &r1, i); | |||
break; | break; | |||
case cPrimEllipsoid: | case cPrimEllipsoid: | |||
BasisGetEllipsoidNormal(bp1, &r1, i, perspective); | BasisGetEllipsoidNormal(bp1, &r1, i, perspective); | |||
RayReflectAndTexture(I, &r1, perspective); | RayReflectAndTexture(I, &r1, perspective); | |||
fc[0] = r1.prim->c1[0]; | fc[0] = r1.prim->c1[0]; | |||
skipping to change at line 3748 | skipping to change at line 3958 | |||
dotgle = -r1.dotgle; | dotgle = -r1.dotgle; | |||
if((interior_color < 0) && (interior_color > cColorExtCutoff )) { | if((interior_color < 0) && (interior_color > cColorExtCutoff )) { | |||
copy3f(r1.prim->ic, fc); | copy3f(r1.prim->ic, fc); | |||
} else { | } else { | |||
copy3f(inter, fc); | copy3f(inter, fc); | |||
} | } | |||
} | } | |||
} | } | |||
if((dotgle < _0) && (!interior_flag)) { | if((r1.flat_dotgle < _0) && (!interior_flag)) { | |||
if(two_sided_lighting) { | if(two_sided_lighting) { | |||
dotgle = -dotgle; | dotgle = -dotgle; | |||
invert3f(r1.surfnormal); | invert3f(r1.surfnormal); | |||
} else { | ||||
dotgle = _0; | ||||
} | } | |||
} | } | |||
} | } | |||
{ | { | |||
double pow_dotgle; | double pow_dotgle; | |||
float pow_surfnormal2; | float pow_surfnormal2; | |||
if(settingPower != _1) { | if(settingPower != _1) { | |||
pow_dotgle = pow(dotgle, settingPower); | pow_dotgle = pow(dotgle, settingPower); | |||
skipping to change at line 3787 | skipping to change at line 3995 | |||
(float) (pow(r1.surfnormal[2], settingSpecDirectPower) * | (float) (pow(r1.surfnormal[2], settingSpecDirectPower) * | |||
settingSpecDirect); | settingSpecDirect); | |||
} else { | } else { | |||
excess = _0; | excess = _0; | |||
} | } | |||
} else { | } else { | |||
excess = _0; | excess = _0; | |||
} | } | |||
lit = _1; | lit = _1; | |||
if(n_basis < 3) { | if(n_basis_tmp < 3) { | |||
reflect_cmp = direct_cmp; | reflect_cmp = direct_cmp; | |||
} else { | } else { | |||
int bc; | int bc; | |||
CBasis *bp; | CBasis *bp; | |||
for(bc = 2; bc < n_basis; bc++) { | for(bc = 2; bc < n_basis; bc++) { | |||
lit = _1; | lit = _1; | |||
bp = I->Basis + bc; | bp = I->Basis + bc; | |||
if(shadows && ((!interior_flag) || (interior_shadows)) && | if(shadows && ((!interior_flag) || (interior_shadows)) && | |||
((r1.prim->type != cPrimCharacter) || (label_shadow_mode & 0x1))) { | ((r1.prim->type != cPrimCharacter) || (label_shadow_mode & 0x1))) { | |||
skipping to change at line 3876 | skipping to change at line 4084 | |||
(float) (pow(dotgle, settingSpecPower) * settingSpecRe flect * | (float) (pow(dotgle, settingSpecPower) * settingSpecRe flect * | |||
lit); | lit); | |||
} else { | } else { | |||
excess += | excess += | |||
(float) (pow(dotgle, settingSpecPower) * settingSpecRe flect * | (float) (pow(dotgle, settingSpecPower) * settingSpecRe flect * | |||
lit * ray_lab_spec); | lit * ray_lab_spec); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
if (chromadepth > 0) { | ||||
float d = -(r1.impact[2] + T->front) / (T->back - T->front); | ||||
const float margin = 1. / 4.; | ||||
float h = d * (1. + 2. * margin) - margin; | ||||
if (h < 0.0) h = 0.0; | ||||
if (h > 1.0) h = 1.0; | ||||
float hue6 = 6. * 240. / 360. * h; | ||||
float rgb[3]; | ||||
rgb[0] = fabs(hue6 - 3.) - 1.; | ||||
rgb[1] = 2. - fabs(hue6 - 2.); | ||||
rgb[2] = 2. - fabs(hue6 - 4.); | ||||
clamp3f(rgb); | ||||
if (chromadepth == 2) { | ||||
float lum = 0.30 * fc[0] + 0.59 * fc[1] + 0.11 * fc[2]; | ||||
rgb[0] *= lum; | ||||
rgb[1] *= lum; | ||||
rgb[2] *= lum; | ||||
} | ||||
copy3(rgb, fc); | ||||
} | ||||
} | } | |||
if(fc[0] <= ((float) cColorExtCutoff)) { /* ramped color */ | if(fc[0] <= ((float) cColorExtCutoff)) { /* ramped color */ | |||
inverse_transformC44f3f(I->ModelView, r1.impact, back_pact); | inverse_transformC44f3f(I->ModelView, r1.impact, back_pact); | |||
ColorGetRamped(I->G, (int) (fc[0] - 0.1F), back_pact, fc, -1); | ColorGetRamped(I->G, (int) (fc[0] - 0.1F), back_pact, fc, -1); | |||
} | } | |||
bright = ambient + (((_1 - direct_shade) + direct_shade * lit) * d irect * direct_cmp + lreflect * reflect_cmp * (legacy_1m + legacy * direct_cmp)) ; /* blend legacy */ | bright = ambient + (((_1 - direct_shade) + direct_shade * lit) * d irect * direct_cmp + lreflect * reflect_cmp * (legacy_1m + legacy * direct_cmp)) ; /* blend legacy */ | |||
if(excess > _1) | if(excess > _1) | |||
excess = _1; | excess = _1; | |||
skipping to change at line 3897 | skipping to change at line 4125 | |||
bright = _1; | bright = _1; | |||
else if(bright < _0) | else if(bright < _0) | |||
bright = _0; | bright = _0; | |||
/* bright *= (_1-excess); */ | /* bright *= (_1-excess); */ | |||
fc[0] = (bright * fc[0] + excess); | fc[0] = (bright * fc[0] + excess); | |||
fc[1] = (bright * fc[1] + excess); | fc[1] = (bright * fc[1] + excess); | |||
fc[2] = (bright * fc[2] + excess); | fc[2] = (bright * fc[2] + excess); | |||
if(fogFlag) { | if(n_basis_tmp && fogFlagTmp) { | |||
if(perspective) { | if(perspective) { | |||
ffact = (T->front + r1.impact[2]) * invFrontMinusBack; | ffact = (T->front + r1.impact[2]) * invFrontMinusBack; | |||
} else { | } else { | |||
ffact = (T->front - r1.dist) * invFrontMinusBack; | ffact = (T->front - r1.dist) * invFrontMinusBack; | |||
} | } | |||
if(fogRangeFlag) | if(fogRangeFlag) | |||
ffact = (ffact - fog_start) * inv1minusFogStart; | ffact = (ffact - fog_start) * inv1minusFogStart; | |||
ffact *= fog; | ffact *= fog; | |||
skipping to change at line 4021 | skipping to change at line 4249 | |||
cc3 = (uint) (fc[3] * _255); | cc3 = (uint) (fc[3] * _255); | |||
if(cc3 > 255) | if(cc3 > 255) | |||
cc3 = 255; | cc3 = 255; | |||
if(I->BigEndian) | if(I->BigEndian) | |||
*pixel = (cc0 << 24) | (cc1 << 16) | (cc2 << 8) | cc3; | *pixel = (cc0 << 24) | (cc1 << 16) | (cc2 << 8) | cc3; | |||
else | else | |||
*pixel = (cc3 << 24) | (cc2 << 16) | (cc1 << 8) | cc0; | *pixel = (cc3 << 24) | (cc2 << 16) | (cc1 << 8) | cc0; | |||
} | } | |||
} | } | |||
if(pass && persist < 1.f) { /* average all four channels */ | ||||
if(pass) { /* average all four channels */ | ||||
float mix_in; | float mix_in; | |||
if(i >= 0) { | if(i >= 0) { | |||
if(fogFlag) { | if(fogFlagTmp) { | |||
if(trans_cont_flag && (ffact > _p5)) { | if(trans_cont_flag && (ffact > _p5)) { | |||
mix_in = | mix_in = | |||
2 * (persist * (_1 - ffact) + | 2 * (persist * (_1 - ffact) + | |||
((float) pow(persist, trans_cont) * (ffact - _p5))) | ((float) pow(persist, trans_cont) * (ffact - _p5))) | |||
* (_1 - r1.trans * ffact); | * (_1 - r1.trans * ffact); | |||
} else { | } else { | |||
mix_in = persist * (_1 - r1.trans * ffact); | mix_in = persist * (_1 - r1.trans * ffact); | |||
} | } | |||
} else { | } else { | |||
mix_in = persist * (_1 - r1.trans); | mix_in = persist * (_1 - r1.trans); | |||
skipping to change at line 4150 | skipping to change at line 4377 | |||
if(r1.prim->type == cPrimSausage) { /* carry ray through the stick */ | if(r1.prim->type == cPrimSausage) { /* carry ray through the stick */ | |||
if(perspective) | if(perspective) | |||
excl_trans = (2 * r1.surfnormal[2] * r1.prim->r1 / r1.dir[2]); | excl_trans = (2 * r1.surfnormal[2] * r1.prim->r1 / r1.dir[2]); | |||
else | else | |||
excl_trans = new_front + (2 * r1.surfnormal[2] * r1.prim->r1); | excl_trans = new_front + (2 * r1.surfnormal[2] * r1.prim->r1); | |||
} | } | |||
if((!backface_cull) && (trans_mode != 2)) | if((!backface_cull) && (trans_mode != 2)) | |||
persist = persist * r1.trans; | persist = persist * r1.trans; | |||
else { | else { | |||
if((persist < 0.9999F) && (r1.trans > 0.05F)) { | if(!r1.prim->no_lighting && (persist < 0.9999F) && (r1.trans > 0 .05F)) { | |||
/* don't combine transparent surfaces */ | /* don't combine transparent surfaces */ | |||
*pixel = last_pixel; | *pixel = last_pixel; | |||
} else { | } else { | |||
persist = persist * r1.trans; | persist = persist * r1.trans; | |||
} | } | |||
} | } | |||
} | } | |||
if(i < 0) { /* nothing hit */ | if(i < 0) { /* nothing hit */ | |||
break; | break; | |||
skipping to change at line 4240 | skipping to change at line 4467 | |||
} | } | |||
{ | { | |||
/* If final pixel has alpha, then the background should be | /* If final pixel has alpha, then the background should be | |||
blended into it */ | blended into it */ | |||
unsigned char *pixel_c = (unsigned char *) pixel; | unsigned char *pixel_c = (unsigned char *) pixel; | |||
if (pixel_c[3] < 255){ | if (pixel_c[3] < 255){ | |||
float pixa = (pixel_c[3]/255.f); | float pixa = (pixel_c[3]/255.f); | |||
float pixam1 = _1 - pixa; | float pixam1 = _1 - pixa; | |||
float pixam1255 = pixam1 * 255.f; | float pixam1255 = pixam1 * 255.f; | |||
if (T->bkrd_is_gradient){ | if (T->bkrd_data || T->bkrd_is_gradient){ | |||
pixel_c[0] = (unsigned char)pymol_roundf(pixel_c[0] * pixa + bkrd [0] * pixam1255); | pixel_c[0] = (unsigned char)pymol_roundf(pixel_c[0] * pixa + bkrd [0] * pixam1255); | |||
pixel_c[1] = (unsigned char)pymol_roundf(pixel_c[1] * pixa + bkrd [1] * pixam1255); | pixel_c[1] = (unsigned char)pymol_roundf(pixel_c[1] * pixa + bkrd [1] * pixam1255); | |||
pixel_c[2] = (unsigned char)pymol_roundf(pixel_c[2] * pixa + bkrd [2] * pixam1255); | pixel_c[2] = (unsigned char)pymol_roundf(pixel_c[2] * pixa + bkrd [2] * pixam1255); | |||
pixel_c[3] = (unsigned char)pymol_roundf(pixel_c[3] * pixa + bkrd [3] * pixam1255); | pixel_c[3] = (unsigned char)pymol_roundf(pixel_c[3] * pixa + bkrd [3] * pixam1255); | |||
} | } | |||
} | } | |||
} | } | |||
if(!T->edging) | if(!T->edging) | |||
break; | break; | |||
skipping to change at line 5294 | skipping to change at line 5521 | |||
extern int n_cells; | extern int n_cells; | |||
extern int n_prims; | extern int n_prims; | |||
extern int n_triangles; | extern int n_triangles; | |||
extern int n_spheres; | extern int n_spheres; | |||
extern int n_cylinders; | extern int n_cylinders; | |||
extern int n_sausages; | extern int n_sausages; | |||
extern int n_skipped; | extern int n_skipped; | |||
#endif | #endif | |||
float *rayDepthPixels = NULL; | float *rayDepthPixels = NULL; | |||
int rayVolume = 0; | int rayVolume = 0, rayWidth = 0, rayHeight = 0; | |||
/*========================================================================*/ | /*========================================================================*/ | |||
void RayRender(CRay * I, unsigned int *image, double timing, | void RayRender(CRay * I, unsigned int *image, double timing, | |||
float angle, int antialias, unsigned int *return_bg) | float angle, int antialias, unsigned int *return_bg) | |||
{ | { | |||
int a, x, y; | int a, x, y; | |||
unsigned int *image_copy = NULL; | unsigned int *image_copy = NULL; | |||
unsigned int back_mask, fore_mask = 0, trace_word = 0; | unsigned int back_mask, fore_mask = 0, trace_word = 0; | |||
unsigned int background; | unsigned int background; | |||
size_t buffer_size; | size_t buffer_size; | |||
int orig_opaque_back = 0, opaque_back = 0; | int orig_opaque_back = 0, opaque_back = 0; | |||
int n_hit = 0; | int n_hit = 0; | |||
float *bkrd_ptr; | const float *bkrd_ptr; | |||
float bkrd_top[3], bkrd_bottom[3]; | float bkrd_top[3], bkrd_bottom[3]; | |||
short bkrd_is_gradient; /* if not gradient, use bkrd_top as bkrd */ | short bkrd_is_gradient; /* if not gradient, use bkrd_top as bkrd */ | |||
double now; | double now; | |||
int shadows; | int shadows; | |||
int n_thread; | int n_thread; | |||
int mag = 1; | int mag = 1; | |||
int oversample_cutoff; | int oversample_cutoff; | |||
int perspective = SettingGetGlobal_i(I->G, cSetting_ray_orthoscopic); | int perspective = SettingGetGlobal_i(I->G, cSetting_ray_orthoscopic); | |||
int n_light = SettingGetGlobal_i(I->G, cSetting_light_count); | int n_light = SettingGetGlobal_i(I->G, cSetting_light_count); | |||
float ambient; | float ambient; | |||
float *depth = NULL; | float *depth = NULL; | |||
float front = I->Volume[4]; | float front = I->Volume[4]; | |||
float back = I->Volume[5]; | float back = I->Volume[5]; | |||
float fov = I->Fov; | float fov = I->Fov; | |||
float *pos = I->Pos; | float *pos = I->Pos; | |||
size_t width = I->Width; | size_t width = I->Width; | |||
size_t height = I->Height; | size_t height = I->Height; | |||
int ray_trace_mode; | int ray_trace_mode; | |||
const float _0 = 0.0F, _p499 = 0.499F; | const float _0 = 0.0F, _p499 = 0.499F; | |||
int volume; | int volume; | |||
short bkgrd_data_allocated = 0; | ||||
const char * bg_image_filename; | ||||
unsigned char *old_bkgrd_data = NULL; | ||||
int ok = true; | int ok = true; | |||
if(n_light > 10) | if(n_light > 10) | |||
n_light = 10; | n_light = 10; | |||
if(perspective < 0) | if(perspective < 0) | |||
perspective = SettingGetGlobal_b(I->G, cSetting_ortho); | perspective = SettingGetGlobal_b(I->G, cSetting_ortho); | |||
perspective = !perspective; | perspective = !perspective; | |||
VLACacheSize(I->G, I->Primitive, CPrimitive, I->NPrimitive, 0, cCache_ray_prim itive); | VLACacheSize(I->G, I->Primitive, CPrimitive, I->NPrimitive, 0, cCache_ray_prim itive); | |||
skipping to change at line 5403 | skipping to change at line 5633 | |||
buffer_size = width * height; | buffer_size = width * height; | |||
} | } | |||
if(ray_trace_mode) { | if(ray_trace_mode) { | |||
depth = Calloc(float, width * height); | depth = Calloc(float, width * height); | |||
} else if(oversample_cutoff) { | } else if(oversample_cutoff) { | |||
depth = Calloc(float, width * height); | depth = Calloc(float, width * height); | |||
} | } | |||
ambient = SettingGetGlobal_f(I->G, cSetting_ambient); | ambient = SettingGetGlobal_f(I->G, cSetting_ambient); | |||
bkrd_is_gradient = SettingGetGlobal_b(I->G, cSetting_bg_gradient); | bkrd_is_gradient = SettingGetGlobal_b(I->G, cSetting_bg_gradient); | |||
bg_image_filename = SettingGet_s(I->G, NULL, NULL, cSetting_bg_image_filename) | ||||
; | ||||
old_bkgrd_data = I->bkgrd_data; | ||||
I->bkgrd_data = (unsigned char*) OrthoBackgroundDataGet(I->G, &I->bkgrd_width, | ||||
&I->bkgrd_height); | ||||
if (!I->bkgrd_data && bg_image_filename && bg_image_filename[0] && I->bkgrd_wi | ||||
dth > 0 && I->bkgrd_height > 0){ | ||||
if (old_bkgrd_data){ | ||||
free(old_bkgrd_data); | ||||
} | ||||
if(MyPNGRead(bg_image_filename, | ||||
(unsigned char **) &I->bkgrd_data, | ||||
(unsigned int *) &I->bkgrd_width, (unsigned int *) &I->bkgrd_hei | ||||
ght)) { | ||||
bkgrd_data_allocated = 1; | ||||
bkrd_is_gradient = 0; | ||||
} | ||||
} | ||||
if (I->bkgrd_data){ | ||||
opaque_back = 1; | ||||
} | ||||
if (!opaque_back){ | if (!opaque_back){ | |||
bkrd_is_gradient = 0; | bkrd_is_gradient = 0; | |||
} | } | |||
if (bkrd_is_gradient){ | if (bkrd_is_gradient){ | |||
bkrd_ptr = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb _top)); | bkrd_ptr = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb _top)); | |||
copy3f(bkrd_ptr, bkrd_top); | copy3f(bkrd_ptr, bkrd_top); | |||
bkrd_ptr = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb _bottom)); | bkrd_ptr = ColorGet(I->G, SettingGet_color(I->G, NULL, NULL, cSetting_bg_rgb _bottom)); | |||
copy3f(bkrd_ptr, bkrd_bottom); | copy3f(bkrd_ptr, bkrd_bottom); | |||
} else { | } else { | |||
skipping to change at line 5460 | skipping to change at line 5707 | |||
bkrd_bottom[1] = 1.0F; | bkrd_bottom[1] = 1.0F; | |||
if(bkrd_bottom[2] > 1.0F) | if(bkrd_bottom[2] > 1.0F) | |||
bkrd_bottom[2] = 1.0F; | bkrd_bottom[2] = 1.0F; | |||
} else { | } else { | |||
copy3f(bkrd_top, bkrd_bottom); | copy3f(bkrd_top, bkrd_bottom); | |||
} | } | |||
if(ray_trace_mode) { | if(ray_trace_mode) { | |||
float inp; | float inp; | |||
float sig; | float sig; | |||
int trace_color = SettingGetGlobal_color(I->G, cSetting_ray_trace_color); | int trace_color = SettingGetGlobal_color(I->G, cSetting_ray_trace_color); | |||
float trgb[3], *trgb_v = ColorGet(I->G, trace_color); | float trgb[3]; | |||
const float *trgb_v = ColorGet(I->G, trace_color); | ||||
copy3f(trgb_v, trgb); | copy3f(trgb_v, trgb); | |||
inp = (trgb[0] + trgb[1] + trgb[2]) / 3.0F; | inp = (trgb[0] + trgb[1] + trgb[2]) / 3.0F; | |||
if(inp < R_SMALL4) | if(inp < R_SMALL4) | |||
sig = 1.0F; | sig = 1.0F; | |||
else | else | |||
sig = (float) (pow(inp, gamma)) / inp; | sig = (float) (pow(inp, gamma)) / inp; | |||
trgb[0] *= sig; | trgb[0] *= sig; | |||
trgb[1] *= sig; | trgb[1] *= sig; | |||
trgb[2] *= sig; | trgb[2] *= sig; | |||
skipping to change at line 5528 | skipping to change at line 5776 | |||
if (!bkrd_is_gradient) { | if (!bkrd_is_gradient) { | |||
PRINTFB(I->G, FB_Ray, FB_Blather) | PRINTFB(I->G, FB_Ray, FB_Blather) | |||
" RayNew: Background = %x %d %d %d\n", background, (int) (bkrd_top[0] * 25 5), | " RayNew: Background = %x %d %d %d\n", background, (int) (bkrd_top[0] * 25 5), | |||
(int) (bkrd_top[1] * 255), (int) (bkrd_top[2] * 255) | (int) (bkrd_top[1] * 255), (int) (bkrd_top[2] * 255) | |||
ENDFB(I->G); | ENDFB(I->G); | |||
} | } | |||
if(return_bg) | if(return_bg) | |||
*return_bg = background; | *return_bg = background; | |||
if(!I->NPrimitive) { /* nothing to render! */ | if(!I->NPrimitive) { /* nothing to render! */ | |||
if (bkrd_is_gradient) { | if (I->bkgrd_data){ | |||
fill_background_image(I, image, width, height, width * (unsigned int) heig | ||||
ht); | ||||
} else if (bkrd_is_gradient) { | ||||
fill_gradient(I, opaque_back, image, bkrd_top, bkrd_bottom, width, height, width * (unsigned int) height); | fill_gradient(I, opaque_back, image, bkrd_top, bkrd_bottom, width, height, width * (unsigned int) height); | |||
} else { | } else { | |||
fill(image, background, width * (unsigned int) height); | fill(image, background, width * (unsigned int) height); | |||
} | } | |||
} else { | } else { | |||
if(I->PrimSizeCnt) { | if(I->PrimSizeCnt) { | |||
float factor = SettingGetGlobal_f(I->G, cSetting_ray_hint_camera); | float factor = SettingGetGlobal_f(I->G, cSetting_ray_hint_camera); | |||
I->PrimSize = I->PrimSize / (I->PrimSizeCnt * factor); | I->PrimSize = I->PrimSize / (I->PrimSizeCnt * factor); | |||
/* printf("avg dist %8.7f\n",I->PrimSize); */ | /* printf("avg dist %8.7f\n",I->PrimSize); */ | |||
skipping to change at line 5653 | skipping to change at line 5903 | |||
thread_info[0].n_prim = I->NPrimitive; | thread_info[0].n_prim = I->NPrimitive; | |||
thread_info[0].clipBox = I->Volume; | thread_info[0].clipBox = I->Volume; | |||
thread_info[0].phase = 0; | thread_info[0].phase = 0; | |||
thread_info[0].perspective = perspective; | thread_info[0].perspective = perspective; | |||
thread_info[0].front = front; | thread_info[0].front = front; | |||
thread_info[0].image = image; | thread_info[0].image = image; | |||
thread_info[0].bkrd_is_gradient = bkrd_is_gradient; | thread_info[0].bkrd_is_gradient = bkrd_is_gradient; | |||
thread_info[0].width = width; | thread_info[0].width = width; | |||
thread_info[0].height = height; | thread_info[0].height = height; | |||
if (bkrd_is_gradient){ | if (I->bkgrd_data){ | |||
thread_info[0].background = background; | ||||
thread_info[0].opaque_back = opaque_back; | ||||
} else if (bkrd_is_gradient){ | ||||
thread_info[0].bkrd_top = bkrd_top; | thread_info[0].bkrd_top = bkrd_top; | |||
thread_info[0].bkrd_bottom = bkrd_bottom; | thread_info[0].bkrd_bottom = bkrd_bottom; | |||
thread_info[0].opaque_back = opaque_back; | thread_info[0].opaque_back = opaque_back; | |||
} else { | } else { | |||
thread_info[0].background = background; | thread_info[0].background = background; | |||
} | } | |||
thread_info[0].bytes = width * (unsigned int) height; | thread_info[0].bytes = width * (unsigned int) height; | |||
thread_info[0].ray = I; /* for compute box */ | thread_info[0].ray = I; /* for compute box */ | |||
thread_info[0].size_hint = I->PrimSize; | thread_info[0].size_hint = I->PrimSize; | |||
/* shadow map */ | /* shadow map */ | |||
skipping to change at line 5707 | skipping to change at line 5960 | |||
float factor = SettingGetGlobal_f(I->G, cSetting_ray_hint_shadow); | float factor = SettingGetGlobal_f(I->G, cSetting_ray_hint_shadow); | |||
for(bc = 2; ok && bc < I->NBasis; bc++) { | for(bc = 2; ok && bc < I->NBasis; bc++) { | |||
ok &= BasisMakeMap(I->Basis + bc, I->Vert2Prim, I->Primitive, I->NPrim itive, | ok &= BasisMakeMap(I->Basis + bc, I->Vert2Prim, I->Primitive, I->NPrim itive, | |||
NULL, bc - 1, cCache_ray_map, false, _0, I->PrimSize * factor); | NULL, bc - 1, cCache_ray_map, false, _0, I->PrimSize * factor); | |||
} | } | |||
} | } | |||
/* serial tasks which RayHashThread does in parallel mode using the first thread */ | /* serial tasks which RayHashThread does in parallel mode using the first thread */ | |||
if (ok){ | if (ok){ | |||
if (bkrd_is_gradient) { | if (I->bkgrd_data){ | |||
fill_background_image(I, image, width, height, width * (unsigned int) | ||||
height); | ||||
} else if (bkrd_is_gradient) { | ||||
fill_gradient(I, opaque_back, image, bkrd_top, bkrd_bottom, width, heig ht, width * (unsigned int) height); | fill_gradient(I, opaque_back, image, bkrd_top, bkrd_bottom, width, heig ht, width * (unsigned int) height); | |||
} else { | } else { | |||
fill(image, background, width * (unsigned int) height); | fill(image, background, width * (unsigned int) height); | |||
} | } | |||
RayComputeBox(I); | RayComputeBox(I); | |||
} | } | |||
} | } | |||
OrthoBusyFast(I->G, 5, 20); | OrthoBusyFast(I->G, 5, 20); | |||
skipping to change at line 5856 | skipping to change at line 6111 | |||
rt[a].ambient = ambient; | rt[a].ambient = ambient; | |||
rt[a].background = background; | rt[a].background = background; | |||
rt[a].phase = a; | rt[a].phase = a; | |||
rt[a].n_thread = n_thread; | rt[a].n_thread = n_thread; | |||
rt[a].edging = NULL; | rt[a].edging = NULL; | |||
rt[a].edging_cutoff = oversample_cutoff; /* info needed for busy indicator */ | rt[a].edging_cutoff = oversample_cutoff; /* info needed for busy indicator */ | |||
rt[a].perspective = perspective; | rt[a].perspective = perspective; | |||
rt[a].fov = fov; | rt[a].fov = fov; | |||
rt[a].pos[2] = pos[2]; | rt[a].pos[2] = pos[2]; | |||
rt[a].depth = depth; | rt[a].depth = depth; | |||
rt[a].bgWidth = I->bkgrd_width; | ||||
rt[a].bgHeight = I->bkgrd_height; | ||||
rt[a].bkrd_data = I->bkgrd_data; | ||||
} | } | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
if(n_thread > 1) | if(n_thread > 1) | |||
RayTraceSpawn(rt, n_thread); | RayTraceSpawn(rt, n_thread); | |||
else | else | |||
#endif | #endif | |||
RayTraceThread(rt); | RayTraceThread(rt); | |||
if(oversample_cutoff) { /* perform edge oversampling, if requested */ | if(oversample_cutoff) { /* perform edge oversampling, if requested */ | |||
skipping to change at line 6032 | skipping to change at line 6290 | |||
} | } | |||
p = tmp; | p = tmp; | |||
tmp = depth; | tmp = depth; | |||
depth = p; | depth = p; | |||
} | } | |||
FreeP(tmp); | FreeP(tmp); | |||
} | } | |||
{ | { | |||
unsigned int *q = image; | unsigned int *q = image; | |||
float *p = delta; | float *p = delta; | |||
int dc = 0; | ||||
int width3 = width * 3; | int width3 = width * 3; | |||
float slope_f = SettingGetGlobal_f(I->G, cSetting_ray_trace_slope_fact or); | float slope_f = SettingGetGlobal_f(I->G, cSetting_ray_trace_slope_fact or); | |||
float depth_f = SettingGetGlobal_f(I->G, cSetting_ray_trace_depth_fact or); | float depth_f = SettingGetGlobal_f(I->G, cSetting_ray_trace_depth_fact or); | |||
float disco_f = SettingGetGlobal_f(I->G, cSetting_ray_trace_disco_fact or); | float disco_f = SettingGetGlobal_f(I->G, cSetting_ray_trace_disco_fact or); | |||
float diff, max_depth; | float diff, max_depth; | |||
float dot, min_dot, max_slope, max_dz, max_pz; | float dot, min_dot, max_slope, max_dz, max_pz; | |||
float dx, dy, dz, px = 0.0F, py = 0.0F, pz = 0.0F, ddx, ddy; | float dx, dy, dz, px = 0.0F, py = 0.0F, pz = 0.0F, ddx, ddy; | |||
const float _8 = 0.08F; | const float _8 = 0.08F; | |||
const float _4 = 0.4F; | const float _4 = 0.4F; | |||
skipping to change at line 6080 | skipping to change at line 6337 | |||
((0xFF & ((unsigned int) (bkrd[1] * 255 + _p499))) << 16) | | ((0xFF & ((unsigned int) (bkrd[1] * 255 + _p499))) << 16) | | |||
((0xFF & ((unsigned int) (bkrd[2] * 255 + _p499))) << 8); | ((0xFF & ((unsigned int) (bkrd[2] * 255 + _p499))) << 8); | |||
} else { | } else { | |||
background = back_mask | | background = back_mask | | |||
((0xFF & ((unsigned int) (bkrd[2] * 255 + _p499))) << 16) | | ((0xFF & ((unsigned int) (bkrd[2] * 255 + _p499))) << 16) | | |||
((0xFF & ((unsigned int) (bkrd[1] * 255 + _p499))) << 8) | | ((0xFF & ((unsigned int) (bkrd[1] * 255 + _p499))) << 8) | | |||
((0xFF & ((unsigned int) (bkrd[0] * 255 + _p499)))); | ((0xFF & ((unsigned int) (bkrd[0] * 255 + _p499)))); | |||
} | } | |||
} | } | |||
for(x = 0; x < width; x++) { | for(x = 0; x < width; x++) { | |||
dc = 0; | ||||
max_slope = 0.0F; | max_slope = 0.0F; | |||
max_depth = 0.0F; | max_depth = 0.0F; | |||
min_dot = 1.0F; | min_dot = 1.0F; | |||
max_dz = 0.0F; | max_dz = 0.0F; | |||
max_pz = 0.0F; | max_pz = 0.0F; | |||
dx = p[0]; | dx = p[0]; | |||
dy = p[1]; | dy = p[1]; | |||
dz = p[2]; | dz = p[2]; | |||
for(i = 0; i < 8; i++) { | for(i = 0; i < 8; i++) { | |||
switch (i) { | switch (i) { | |||
skipping to change at line 6307 | skipping to change at line 6563 | |||
for(y = 0; y < height; y++) { | for(y = 0; y < height; y++) { | |||
for(x = 0; x < width; x++) { | for(x = 0; x < width; x++) { | |||
float dd = depth[x+width*y]; | float dd = depth[x+width*y]; | |||
if (dd == 0.0) dd = -back; | if (dd == 0.0) dd = -back; | |||
depth[x+width*y] = -dd/(back-front) + 0.1; | depth[x+width*y] = -dd/(back-front) + 0.1; | |||
} | } | |||
} | } | |||
if (rayDepthPixels) | if (rayDepthPixels) | |||
FreeP(rayDepthPixels); | FreeP(rayDepthPixels); | |||
rayDepthPixels = depth; | rayDepthPixels = depth; | |||
rayWidth = width; | ||||
rayHeight = height; | ||||
rayVolume = 3; | rayVolume = 3; | |||
} else | } else | |||
FreeP(depth); | FreeP(depth); | |||
if (bkgrd_data_allocated && I->bkgrd_data){ | ||||
free(I->bkgrd_data); | ||||
} | ||||
} | } | |||
I->bkgrd_data = NULL; | ||||
} | } | |||
void RayRenderColorTable(CRay * I, int width, int height, int *image) | void RayRenderColorTable(CRay * I, int width, int height, int *image) | |||
{ | { | |||
int x, y; | int x, y; | |||
unsigned int r = 0, g = 0, b = 0; | unsigned int r = 0, g = 0, b = 0; | |||
unsigned int *pixel, mask, *p; | unsigned int *pixel, mask, *p; | |||
if(I->BigEndian) | if(I->BigEndian) | |||
mask = 0x000000FF; | mask = 0x000000FF; | |||
skipping to change at line 6410 | skipping to change at line 6672 | |||
CHECKOK(ok, I->Primitive); | CHECKOK(ok, I->Primitive); | |||
if (!ok) | if (!ok) | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimSphere; | p->type = cPrimSphere; | |||
p->r1 = r; | p->r1 = r; | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = (I->CurColor[0] < 0.0F); | p->ramped = (I->CurColor[0] < 0.0F); | |||
p->no_lighting = 0; | ||||
I->PrimSize += 2 * r; | I->PrimSize += 2 * r; | |||
I->PrimSizeCnt++; | I->PrimSizeCnt++; | |||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
vv = p->v1; | vv = p->v1; | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
skipping to change at line 6434 | skipping to change at line 6697 | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
vv = p->ic; | vv = p->ic; | |||
v = I->IntColor; | v = I->IntColor; | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
if(I->TTTFlag) { | if(I->TTTFlag) { | |||
p->r1 *= length3f(I->TTT); | ||||
transformTTT44f3f(I->TTT, p->v1, p->v1); | transformTTT44f3f(I->TTT, p->v1, p->v1); | |||
} | } | |||
if(I->Context) { | if(I->Context) { | |||
RayApplyContextToVertex(I, p->v1); | RayApplyContextToVertex(I, p->v1); | |||
} | } | |||
I->NPrimitive++; | I->NPrimitive++; | |||
return true; | return true; | |||
} | } | |||
skipping to change at line 6495 | skipping to change at line 6759 | |||
CHECKOK(ok, I->Primitive); | CHECKOK(ok, I->Primitive); | |||
if (!ok) | if (!ok) | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimCharacter; | p->type = cPrimCharacter; | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->char_id = char_id; | p->char_id = char_id; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = 0; | p->ramped = 0; | |||
p->no_lighting = 0; | ||||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
vv = p->v1; | vv = p->v1; | |||
(*vv++) = v[0]; | (*vv++) = v[0]; | |||
(*vv++) = v[1]; | (*vv++) = v[1]; | |||
(*vv++) = v[2]; | (*vv++) = v[2]; | |||
if(I->TTTFlag) { | if(I->TTTFlag) { | |||
transformTTT44f3f(I->TTT, p->v1, p->v1); | transformTTT44f3f(I->TTT, p->v1, p->v1); | |||
skipping to change at line 6629 | skipping to change at line 6894 | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimCylinder; | p->type = cPrimCylinder; | |||
p->r1 = r; | p->r1 = r; | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->cap1 = cCylCapFlat; | p->cap1 = cCylCapFlat; | |||
p->cap2 = cCylCapFlat; | p->cap2 = cCylCapFlat; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | |||
p->no_lighting = 0; | ||||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
vv = p->v1; | vv = p->v1; | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
vv = p->v2; | vv = p->v2; | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
I->PrimSize += diff3f(p->v1, p->v2) + 2 * r; | I->PrimSize += diff3f(p->v1, p->v2) + 2 * r; | |||
I->PrimSizeCnt++; | I->PrimSizeCnt++; | |||
if(I->TTTFlag) { | if(I->TTTFlag) { | |||
p->r1 *= length3f(I->TTT); | ||||
transformTTT44f3f(I->TTT, p->v1, p->v1); | transformTTT44f3f(I->TTT, p->v1, p->v1); | |||
transformTTT44f3f(I->TTT, p->v2, p->v2); | transformTTT44f3f(I->TTT, p->v2, p->v2); | |||
} | } | |||
if(I->Context) { | if(I->Context) { | |||
RayApplyContextToVertex(I, p->v1); | RayApplyContextToVertex(I, p->v1); | |||
RayApplyContextToVertex(I, p->v2); | RayApplyContextToVertex(I, p->v2); | |||
} | } | |||
vv = p->c1; | vv = p->c1; | |||
skipping to change at line 6698 | skipping to change at line 6965 | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimCylinder; | p->type = cPrimCylinder; | |||
p->r1 = r; | p->r1 = r; | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->cap1 = cap1; | p->cap1 = cap1; | |||
p->cap2 = cap2; | p->cap2 = cap2; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | |||
p->no_lighting = 0; | ||||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
vv = p->v1; | vv = p->v1; | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
vv = p->v2; | vv = p->v2; | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
I->PrimSize += diff3f(p->v1, p->v2) + 2 * r; | I->PrimSize += diff3f(p->v1, p->v2) + 2 * r; | |||
I->PrimSizeCnt++; | I->PrimSizeCnt++; | |||
if(I->TTTFlag) { | if(I->TTTFlag) { | |||
p->r1 *= length3f(I->TTT); | ||||
transformTTT44f3f(I->TTT, p->v1, p->v1); | transformTTT44f3f(I->TTT, p->v1, p->v1); | |||
transformTTT44f3f(I->TTT, p->v2, p->v2); | transformTTT44f3f(I->TTT, p->v2, p->v2); | |||
} | } | |||
if(I->Context) { | if(I->Context) { | |||
RayApplyContextToVertex(I, p->v1); | RayApplyContextToVertex(I, p->v1); | |||
RayApplyContextToVertex(I, p->v2); | RayApplyContextToVertex(I, p->v2); | |||
} | } | |||
vv = p->c1; | vv = p->c1; | |||
skipping to change at line 6792 | skipping to change at line 7061 | |||
p->cap1 = cap1; | p->cap1 = cap1; | |||
if(cap2 >= cCylCapFlat) | if(cap2 >= cCylCapFlat) | |||
cap2 = cCylCapFlat; | cap2 = cCylCapFlat; | |||
if(cap1 >= cCylCapFlat) | if(cap1 >= cCylCapFlat) | |||
cap1 = cCylCapFlat; | cap1 = cCylCapFlat; | |||
p->cap2 = cap2; | p->cap2 = cap2; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | |||
p->no_lighting = 0; | ||||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
vv = p->v1; | vv = p->v1; | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
vv = p->v2; | vv = p->v2; | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
skipping to change at line 6858 | skipping to change at line 7128 | |||
CHECKOK(ok, I->Primitive); | CHECKOK(ok, I->Primitive); | |||
if (!ok) | if (!ok) | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimSausage; | p->type = cPrimSausage; | |||
p->r1 = r; | p->r1 = r; | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F)); | |||
p->no_lighting = 0; | ||||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
vv = p->v1; | vv = p->v1; | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
(*vv++) = (*v1++); | (*vv++) = (*v1++); | |||
vv = p->v2; | vv = p->v2; | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
(*vv++) = (*v2++); | (*vv++) = (*v2++); | |||
I->PrimSize += diff3f(p->v1, p->v2) + 2 * r; | I->PrimSize += diff3f(p->v1, p->v2) + 2 * r; | |||
I->PrimSizeCnt++; | I->PrimSizeCnt++; | |||
if(I->TTTFlag) { | if(I->TTTFlag) { | |||
p->r1 *= length3f(I->TTT); | ||||
transformTTT44f3f(I->TTT, p->v1, p->v1); | transformTTT44f3f(I->TTT, p->v1, p->v1); | |||
transformTTT44f3f(I->TTT, p->v2, p->v2); | transformTTT44f3f(I->TTT, p->v2, p->v2); | |||
} | } | |||
if(I->Context) { | if(I->Context) { | |||
RayApplyContextToVertex(I, p->v1); | RayApplyContextToVertex(I, p->v1); | |||
RayApplyContextToVertex(I, p->v2); | RayApplyContextToVertex(I, p->v2); | |||
} | } | |||
vv = p->c1; | vv = p->c1; | |||
skipping to change at line 6923 | skipping to change at line 7195 | |||
CHECKOK(ok, I->Primitive); | CHECKOK(ok, I->Primitive); | |||
if (!ok) | if (!ok) | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimEllipsoid; | p->type = cPrimEllipsoid; | |||
p->r1 = r; /* maximum extent */ | p->r1 = r; /* maximum extent */ | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = (I->CurColor[0] < 0.0F); | p->ramped = (I->CurColor[0] < 0.0F); | |||
p->no_lighting = 0; | ||||
I->PrimSize += 2 * r; | I->PrimSize += 2 * r; | |||
I->PrimSizeCnt++; | I->PrimSizeCnt++; | |||
vv = p->n0; /* storing lengths of the direction vectors in n 0 */ | vv = p->n0; /* storing lengths of the direction vectors in n 0 */ | |||
(*vv++) = length3f(n1); | (*vv++) = length3f(n1); | |||
(*vv++) = length3f(n2); | (*vv++) = length3f(n2); | |||
(*vv++) = length3f(n3); | (*vv++) = length3f(n3); | |||
skipping to change at line 6992 | skipping to change at line 7265 | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
vv = p->ic; | vv = p->ic; | |||
v = I->IntColor; | v = I->IntColor; | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
(*vv++) = (*v++); | (*vv++) = (*v++); | |||
if(I->TTTFlag) { | if(I->TTTFlag) { | |||
p->r1 *= length3f(I->TTT); | ||||
transformTTT44f3f(I->TTT, p->v1, p->v1); | transformTTT44f3f(I->TTT, p->v1, p->v1); | |||
transform_normalTTT44f3f(I->TTT, p->n1, p->n1); | transform_normalTTT44f3f(I->TTT, p->n1, p->n1); | |||
transform_normalTTT44f3f(I->TTT, p->n2, p->n2); | transform_normalTTT44f3f(I->TTT, p->n2, p->n2); | |||
transform_normalTTT44f3f(I->TTT, p->n3, p->n3); | transform_normalTTT44f3f(I->TTT, p->n3, p->n3); | |||
} | } | |||
if(I->Context) { | if(I->Context) { | |||
RayApplyContextToVertex(I, p->v1); | RayApplyContextToVertex(I, p->v1); | |||
RayApplyContextToNormal(I, p->n1); | RayApplyContextToNormal(I, p->n1); | |||
RayApplyContextToNormal(I, p->n2); | RayApplyContextToNormal(I, p->n2); | |||
RayApplyContextToNormal(I, p->n3); | RayApplyContextToNormal(I, p->n3); | |||
} | } | |||
I->NPrimitive++; | I->NPrimitive++; | |||
return true; | return true; | |||
} | } | |||
int CRay::setLastToNoLighting(char no_lighting) | int CRay::setLastToNoLighting(char no_lighting) | |||
{ | { | |||
#if 0 | ||||
CRay * I = this; | CRay * I = this; | |||
CPrimitive *p; | CPrimitive *p; | |||
if (!I->NPrimitive) | if (!I->NPrimitive) | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive - 1; | p = I->Primitive + I->NPrimitive - 1; | |||
p->no_lighting = no_lighting; | p->no_lighting = no_lighting; | |||
#endif | ||||
return true; | return true; | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
int CRay::triangle3fv( | int CRay::triangle3fv( | |||
const float *v1, const float *v2, const float *v3, | const float *v1, const float *v2, const float *v3, | |||
const float *n1, const float *n2, const float *n3, const float *c1, const float *c2, const float *c3) | const float *n1, const float *n2, const float *n3, const float *c1, const float *c2, const float *c3) | |||
{ | { | |||
CRay * I = this; | CRay * I = this; | |||
CPrimitive *p; | CPrimitive *p; | |||
skipping to change at line 7057 | skipping to change at line 7329 | |||
return false; | return false; | |||
p = I->Primitive + I->NPrimitive; | p = I->Primitive + I->NPrimitive; | |||
p->type = cPrimTriangle; | p->type = cPrimTriangle; | |||
p->trans = I->Trans; | p->trans = I->Trans; | |||
p->tr[0] = I->Trans; | p->tr[0] = I->Trans; | |||
p->tr[1] = I->Trans; | p->tr[1] = I->Trans; | |||
p->tr[2] = I->Trans; | p->tr[2] = I->Trans; | |||
p->wobble = I->Wobble; | p->wobble = I->Wobble; | |||
p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F) || (c3[0] < 0.0F)); | p->ramped = ((c1[0] < 0.0F) || (c2[0] < 0.0F) || (c3[0] < 0.0F)); | |||
p->no_lighting = 0; | ||||
/* | /* | |||
copy3f(I->WobbleParam,p->wobble_param); */ | copy3f(I->WobbleParam,p->wobble_param); */ | |||
/* determine exact triangle normal */ | /* determine exact triangle normal */ | |||
if (normals_exist){ | if (normals_exist){ | |||
add3f(n1, n2, nx); | add3f(n1, n2, nx); | |||
add3f(n3, nx, nx); | add3f(n3, nx, nx); | |||
} | } | |||
subtract3f(v1, v2, s1); | subtract3f(v1, v2, s1); | |||
subtract3f(v3, v2, s2); | subtract3f(v3, v2, s2); | |||
skipping to change at line 7259 | skipping to change at line 7532 | |||
} | } | |||
I->Wobble = SettingGet_i(I->G, NULL, NULL, cSetting_ray_texture); | I->Wobble = SettingGet_i(I->G, NULL, NULL, cSetting_ray_texture); | |||
{ | { | |||
auto v = SettingGet<const float*>(I->G, cSetting_ray_texture_settings); | auto v = SettingGet<const float*>(I->G, cSetting_ray_texture_settings); | |||
int color = SettingGetGlobal_color(I->G, cSetting_ray_interior_color); | int color = SettingGetGlobal_color(I->G, cSetting_ray_interior_color); | |||
copy3f(v, I->WobbleParam); | copy3f(v, I->WobbleParam); | |||
v = ColorGet(I->G, color); | v = ColorGet(I->G, color); | |||
copy3f(v, I->IntColor); | copy3f(v, I->IntColor); | |||
} | } | |||
I->bkgrd_data = NULL; | ||||
I->bkgrd_width = I->bkgrd_height = 0; | ||||
return (I); | return (I); | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
/* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | /* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | |||
#ifdef PYMOL_EVAL | #ifdef PYMOL_EVAL | |||
#include "RayEvalMessage.h" | #include "RayEvalMessage.h" | |||
#endif | #endif | |||
skipping to change at line 7303 | skipping to change at line 7578 | |||
I->Range[2] = I->Volume[5] - I->Volume[4]; | I->Range[2] = I->Volume[5] - I->Volume[4]; | |||
I->AspRatio = aspRat; | I->AspRatio = aspRat; | |||
I->Width = width; | I->Width = width; | |||
I->Height = height; | I->Height = height; | |||
CharacterSetRetention(I->G, true); | CharacterSetRetention(I->G, true); | |||
if(mat) | if(mat) | |||
for(a = 0; a < 16; a++) | for(a = 0; a < 16; a++) | |||
I->ModelView[a] = mat[a]; | I->ModelView[a] = mat[a]; | |||
else { | else { | |||
for(a = 0; a < 16; a++) | identity44f(I->ModelView); | |||
I->ModelView[a] = 0.0F; | } | |||
for(a = 0; a < 3; a++) | identity44f(I->ProMatrix); | |||
I->ModelView[a * 5] = 1.0F; | if (ortho){ | |||
I->ProMatrix[0] = 2.f/I->Range[0]; | ||||
I->ProMatrix[5] = 2.f/I->Range[1]; | ||||
I->ProMatrix[10] = -2.f/I->Range[2]; | ||||
I->ProMatrix[12] = -(I->Volume[0] + I->Volume[1])/I->Range[0]; | ||||
I->ProMatrix[13] = -(I->Volume[2] + I->Volume[3])/I->Range[1]; | ||||
I->ProMatrix[14] = -(I->Volume[4] + I->Volume[5])/I->Range[2]; | ||||
} else { | ||||
I->ProMatrix[0] = I->Volume[4]/(front_back_ratio*I->Volume[1]); | ||||
I->ProMatrix[5] = I->Volume[4]/(front_back_ratio*I->Volume[3]); | ||||
I->ProMatrix[10] = -(I->Volume[5] + I->Volume[4])/I->Range[2]; | ||||
I->ProMatrix[11] = -1.f; | ||||
I->ProMatrix[14] = (-2.f * I->Volume[5] * I->Volume[4])/I->Range[2]; | ||||
I->ProMatrix[15] = 0.f; | ||||
} | } | |||
if(rotMat) | if(rotMat) | |||
for(a = 0; a < 16; a++) | for(a = 0; a < 16; a++) | |||
I->Rotation[a] = rotMat[a]; | I->Rotation[a] = rotMat[a]; | |||
I->Ortho = ortho; | I->Ortho = ortho; | |||
if(ortho) { | if(ortho) { | |||
I->PixelRadius = (((float) I->Range[0]) / width) * pixel_scale; | I->PixelRadius = (((float) I->Range[0]) / width) * pixel_scale; | |||
} else { | } else { | |||
I->PixelRadius = (((float) I->Range[0]) / width) * pixel_scale * pixel_ratio ; | I->PixelRadius = (((float) I->Range[0]) / width) * pixel_scale * pixel_ratio ; | |||
} | } | |||
skipping to change at line 7474 | skipping to change at line 7762 | |||
for(i = 0; i < n; i++) { | for(i = 0; i < n; i++) { | |||
float p0 = p[i][0], p1 = p[i][1], p2 = p[i][2]; | float p0 = p[i][0], p1 = p[i][1], p2 = p[i][2]; | |||
q[i][0] = m0 * p0 + m1 * p1 + m2 * p2; | q[i][0] = m0 * p0 + m1 * p1 + m2 * p2; | |||
q[i][1] = m4 * p0 + m5 * p1 + m6 * p2; | q[i][1] = m4 * p0 + m5 * p1 + m6 * p2; | |||
q[i][2] = m8 * p0 + m9 * p1 + m10 * p2; | q[i][2] = m8 * p0 + m9 * p1 + m10 * p2; | |||
} | } | |||
for(i = 0; i < n; i++) { /* renormalize - can we do this to the matrix in stead? */ | for(i = 0; i < n; i++) { /* renormalize - can we do this to the matrix in stead? */ | |||
normalize3f(q[i]); | normalize3f(q[i]); | |||
} | } | |||
} | } | |||
void RayGetScreenVertex(CRay * I, float *v, float *res){ | ||||
MatrixTransformC44f4f(I->ModelView, v, res); | ||||
normalize4f(res); | ||||
} | ||||
void RayAdjustZtoScreenZ(CRay * ray, float *pos, float zarg){ | ||||
PyMOLGlobals *G = ray->G; | ||||
float BackSafe = ray->Volume[5], FrontSafe = ray->Volume[4]; | ||||
float clipRange = (BackSafe-FrontSafe); | ||||
float z = (zarg + 1.f) / 2.f; | ||||
float zInPreProj = -(z * clipRange + FrontSafe); | ||||
float pos4[4], tpos[4], npos[4]; | ||||
float InvModMatrix[16]; | ||||
copy3f(pos, pos4); | ||||
pos4[3] = 1.f; | ||||
MatrixTransformC44f4f(ray->ModelView, pos4, tpos); | ||||
normalize4f(tpos); | ||||
/* NEED TO ACCOUNT FOR ORTHO */ | ||||
if (SettingGetGlobal_b(G, cSetting_ortho)){ | ||||
npos[0] = tpos[0]; | ||||
npos[1] = tpos[1]; | ||||
} else { | ||||
npos[0] = zInPreProj * tpos[0] / tpos[2]; | ||||
npos[1] = zInPreProj * tpos[1] / tpos[2]; | ||||
} | ||||
npos[2] = zInPreProj; | ||||
npos[3] = 1.f; | ||||
MatrixInvertC44f(ray->ModelView, InvModMatrix); | ||||
MatrixTransformC44f4f(InvModMatrix, npos, npos); | ||||
normalize4f(npos); | ||||
copy3f(npos, pos); | ||||
} | ||||
static float RayGetRawDepth(CRay * ray, float *pos) | ||||
{ | ||||
float pos4[4], tpos[4]; | ||||
copy3f(pos, pos4); | ||||
pos4[3] = 1.f; | ||||
MatrixTransformC44f4f(ray->ModelView, pos4, tpos); | ||||
normalize4f(tpos); | ||||
return -tpos[2]; | ||||
} | ||||
void RayAdjustZtoScreenZofPoint(CRay * ray, float *pos, float *zpoint){ | ||||
float BackSafe = ray->Volume[5], FrontSafe = ray->Volume[4]; | ||||
float clipRange = (BackSafe-FrontSafe); | ||||
float zInClipping = RayGetRawDepth(ray, zpoint); | ||||
float z = ((2.f * (zInClipping - FrontSafe)/ clipRange) - 1.f); | ||||
RayAdjustZtoScreenZ(ray, pos, z); | ||||
} | ||||
void RaySetPointToWorldScreenRelative(CRay * ray, float *pos, float *screenPt) | ||||
{ | ||||
float npos[4]; | ||||
float PmvMatrix[16], InvPmvMatrix[16]; | ||||
int width = ray->Width, height = ray->Height; | ||||
multiply44f44f44f(ray->ModelView, RayGetProMatrix(ray), PmvMatrix); | ||||
npos[0] = (floor(screenPt[0]*width)) /width ; | ||||
npos[1] = (floor(screenPt[1]*height)) /height ; | ||||
npos[2] = 0.f; | ||||
npos[3] = 1.f; | ||||
MatrixInvertC44f(PmvMatrix, InvPmvMatrix); | ||||
MatrixTransformC44f4f(InvPmvMatrix, npos, npos); | ||||
normalize4f(npos); | ||||
RayAdjustZtoScreenZ(ray, npos, screenPt[2]); | ||||
copy3f(npos, pos); | ||||
} | ||||
float RayGetScaledAllAxesAtPoint(CRay * I, float *pt, float *xn, float *yn, floa | ||||
t *zn) | ||||
{ | ||||
float xn0[3] = { 1.0F, 0.0F, 0.0F }; | ||||
float yn0[3] = { 0.0F, 1.0F, 0.0F }; | ||||
float zn0[3] = { 0.0F, 0.0F, 1.0F }; | ||||
float v_scale; | ||||
v_scale = RayGetScreenVertexScale(I, pt) / I->Sampling; | ||||
RayApplyMatrixInverse33(1, (float3 *) xn0, I->Rotation, (float3 *) xn0); | ||||
RayApplyMatrixInverse33(1, (float3 *) yn0, I->Rotation, (float3 *) yn0); | ||||
RayApplyMatrixInverse33(1, (float3 *) zn0, I->Rotation, (float3 *) zn0); | ||||
scale3f(xn0, v_scale, xn); | ||||
scale3f(yn0, v_scale, yn); | ||||
scale3f(zn0, v_scale, zn); | ||||
return v_scale; | ||||
} | ||||
float* RayGetProMatrix(CRay * I){ | ||||
return I->ProMatrix; | ||||
} | ||||
End of changes. 70 change blocks. | ||||
80 lines changed or deleted | 385 lines changed or added |