"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer1/Ray.cpp" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

Ray.cpp  (pymol-open-source-2.2.0):Ray.cpp  (pymol-open-source-2.3.0)
skipping to change at line 42 skipping to change at line 42
#include"Color.h" #include"Color.h"
#include"Matrix.h" #include"Matrix.h"
#include"P.h" #include"P.h"
#include"MemoryCache.h" #include"MemoryCache.h"
#include"Character.h" #include"Character.h"
#include"Text.h" #include"Text.h"
#include"PyMOL.h" #include"PyMOL.h"
#include"Scene.h" #include"Scene.h"
#include"PConv.h" #include"PConv.h"
#include"MyPNG.h" #include"MyPNG.h"
#include"CGO.h"
#define SettingGetfv SettingGetGlobal_3fv #define SettingGetfv SettingGetGlobal_3fv
#ifdef _PYMOL_INLINE #ifdef _PYMOL_INLINE
#undef _PYMOL_INLINE #undef _PYMOL_INLINE
#include"Basis.cpp" #include"Basis.cpp"
#define _PYMOL_INLINE #define _PYMOL_INLINE
#endif #endif
#ifndef RAY_SMALL #ifndef RAY_SMALL
skipping to change at line 121 skipping to change at line 122
struct _CRayAntiThreadInfo { struct _CRayAntiThreadInfo {
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;
}; };
static
void RayRelease(CRay * I); void RayRelease(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 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);
static
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;
} }
skipping to change at line 353 skipping to change at line 351
mult3f(bg_rgb, alpha, tmpadd2); mult3f(bg_rgb, alpha, tmpadd2);
add3f(tmpadd1, tmpadd2, tmpadd2); add3f(tmpadd1, tmpadd2, tmpadd2);
bkrd[0] = 0xFF & (int)pymol_roundf(tmpadd2[0]); bkrd[0] = 0xFF & (int)pymol_roundf(tmpadd2[0]);
bkrd[1] = 0xFF & (int)pymol_roundf(tmpadd2[1]); bkrd[1] = 0xFF & (int)pymol_roundf(tmpadd2[1]);
bkrd[2] = 0xFF & (int)pymol_roundf(tmpadd2[2]); bkrd[2] = 0xFF & (int)pymol_roundf(tmpadd2[2]);
bkrd[3] = 255; bkrd[3] = 255;
} }
} }
static void fill_background_image(CRay * I, unsigned int *buffer, int width, int height, unsigned int cnt){ 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; int bkgrd_width = I->bkgrd_data->getWidth(), bkgrd_height = I->bkgrd_data->get
unsigned char *bkgrd_data = I->bkgrd_data; Height();
unsigned char *bkgrd_data = I->bkgrd_data->bits();
int bg_image_mode = SettingGetGlobal_i(I->G, cSetting_bg_image_mode); int bg_image_mode = SettingGetGlobal_i(I->G, cSetting_bg_image_mode);
int bg_image_linear = SettingGetGlobal_b(I->G, cSetting_bg_image_linear); int bg_image_linear = SettingGetGlobal_b(I->G, cSetting_bg_image_linear);
float bg_rgb[3]; float bg_rgb[3];
const float *tmpf; const float *tmpf;
int w, h; int w, h;
unsigned int value; unsigned int value;
float wr = bkgrd_width/(float)width, hr = bkgrd_height/(float)height; float wr = bkgrd_width/(float)width, hr = bkgrd_height/(float)height;
float hl; float hl;
unsigned int back_mask; unsigned int back_mask;
unsigned char bkrd[4]; unsigned char bkrd[4];
skipping to change at line 3270 skipping to change at line 3268
int spec_count = SettingGetGlobal_i(I->G, cSetting_spec_count); int spec_count = SettingGetGlobal_i(I->G, cSetting_spec_count);
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;
int bg_image_mode = SettingGetGlobal_i(I->G, cSetting_bg_image_mode); int bg_image_mode = SettingGetGlobal_i(I->G, cSetting_bg_image_mode);
int bg_image_linear = SettingGetGlobal_b(I->G, cSetting_bg_image_linear); 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); 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), float hpixelx = floor(T->width/2.f) - floor(T->bgWidth / 2.f),
hpixely = floor(T->height/2.f) - floor(T->bgHeight / 2.f); hpixely = floor(T->height/2.f) - floor(T->bgHeight / 2.f);
float hl; float hl;
float wr = T->bgWidth/(float)T->width, hr = T->bgHeight/(float)T->height; float wr = T->bgWidth/(float)T->width, hr = T->bgHeight/(float)T->height;
float bg_rgb[3]; float bg_rgb[3];
const float *tmpf; const float *tmpf;
int chromadepth; int chromadepth;
skipping to change at line 3528 skipping to change at line 3525
MapCacheInit(&BasisCall[bc].cache, I->Basis[bc].Map, T->phase, MapCacheInit(&BasisCall[bc].cache, I->Basis[bc].Map, T->phase,
cCache_map_shadow_cache); cCache_map_shadow_cache);
} }
} }
if(T->border) { if(T->border) {
border_offset = -1.50F + T->border / 2.0F; border_offset = -1.50F + T->border / 2.0F;
} else { } else {
border_offset = 0.0F; border_offset = 0.0F;
} }
unsigned int back_mask = 0x00000000;
if (T->bkrd_is_gradient){ if (T->bkrd_is_gradient){
if(opaque_back) { if(opaque_back) {
if(I->BigEndian) if(I->BigEndian)
back_mask = 0x000000FF; back_mask = 0x000000FF;
else else
back_mask = 0xFF000000; back_mask = 0xFF000000;
} else {
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] = {0.f, 0.f, 0.f, 1.f};
unsigned int bkrd_value; unsigned int bkrd_value = 0;
short isOutsideInY = 0; 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_data){ if (T->bkrd_data){
switch (bg_image_mode){ switch (bg_image_mode){
case 1: // isCentered case 1: // isCentered
{ {
skipping to change at line 5555 skipping to change at line 5552
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; 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 5634 skipping to change at line 5629
} }
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) ; bg_image_filename = SettingGet_s(I->G, NULL, NULL, cSetting_bg_image_filename) ;
old_bkgrd_data = I->bkgrd_data; I->bkgrd_data = OrthoBackgroundDataGet(*I->G->Ortho);
I->bkgrd_data = (unsigned char*) OrthoBackgroundDataGet(I->G, &I->bkgrd_width, if (!I->bkgrd_data && bg_image_filename && bg_image_filename[0]){
&I->bkgrd_height); I->bkgrd_data = MyPNGRead(bg_image_filename);
if (!I->bkgrd_data && bg_image_filename && bg_image_filename[0] && I->bkgrd_wi bkrd_is_gradient = 0;
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){ if (I->bkgrd_data){
opaque_back = 1; 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));
skipping to change at line 6111 skipping to change at line 6098
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].bkrd_data = I->bkgrd_data ? I->bkgrd_data->bits() : nullptr;
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 6568 skipping to change at line 6553
} }
} }
if (rayDepthPixels) if (rayDepthPixels)
FreeP(rayDepthPixels); FreeP(rayDepthPixels);
rayDepthPixels = depth; rayDepthPixels = depth;
rayWidth = width; rayWidth = width;
rayHeight = height; 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; I->bkgrd_data = nullptr;
} }
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 6874 skipping to change at line 6856
set3f(pp->c2, 0.0F, height, 0.0F); set3f(pp->c2, 0.0F, height, 0.0F);
set3f(pp->c3, width, 0.0F, 0.0F); set3f(pp->c3, width, 0.0F, 0.0F);
} }
I->NPrimitive += 2; I->NPrimitive += 2;
return true; return true;
} }
/*========================================================================*/ /*========================================================================*/
int CRay::cylinder3fv(const float *v1, const float *v2, float r, const float *c1 int CRay::cylinder3fv(const cgo::draw::cylinder &cyl){
, const float *c2) return cylinder3fv(cyl.vertex1, cyl.vertex2, cyl.radius, cyl.color1, cyl.color
2, 1.0f - Trans, 1.0f - Trans);
}
int CRay::cylinder3fv(const cgo::draw::cylinder &cyl, const float alpha1, const
float alpha2){
return cylinder3fv(cyl.vertex1, cyl.vertex2, cyl.radius, cyl.color1, cyl.color
2, alpha1, alpha2);
}
int CRay::cylinder3fv(const float *v1, const float *v2, float r, const float *c1
, const float *c2,
const float alpha1, const float alpha2)
{ {
CRay * I = this; CRay * I = this;
CPrimitive *p; CPrimitive *p;
int ok = true; int ok = true;
float *vv; float *vv;
VLACacheCheck(I->G, I->Primitive, CPrimitive, I->NPrimitive, 0, cCache_ray_pri mitive); VLACacheCheck(I->G, I->Primitive, CPrimitive, I->NPrimitive, 0, cCache_ray_pri mitive);
CHECKOK(ok, I->Primitive); CHECKOK(ok, I->Primitive);
if (!ok) if (!ok)
return false; return false;
skipping to change at line 6930 skipping to change at line 6920
vv = p->c1; vv = p->c1;
(*vv++) = (*c1++); (*vv++) = (*c1++);
(*vv++) = (*c1++); (*vv++) = (*c1++);
(*vv++) = (*c1++); (*vv++) = (*c1++);
vv = p->c2; vv = p->c2;
(*vv++) = (*c2++); (*vv++) = (*c2++);
(*vv++) = (*c2++); (*vv++) = (*c2++);
(*vv++) = (*c2++); (*vv++) = (*c2++);
p->trans = 1.0 - alpha1;
{ {
float *v; float *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++);
} }
I->NPrimitive++; I->NPrimitive++;
return true; return true;
} }
/*========================================================================*/ /*========================================================================*/
int CRay::customCylinder3fv(const cgo::draw::custom_cylinder& cyl, const float a
lpha1, const float alpha2){
return customCylinder3fv(cyl.vertex1, cyl.vertex2, cyl.radius, cyl.color1,
cyl.color2, cyl.cap1, cyl.cap2, alpha1, alpha2);
}
int CRay::customCylinder3fv(const cgo::draw::custom_cylinder& cyl){
return customCylinder3fv(cyl.vertex1, cyl.vertex2, cyl.radius, cyl.color1,
cyl.color2, cyl.cap1, cyl.cap2, 1.f - Trans, 1.f - Trans
);
}
int CRay::customCylinderAlpha3fv(const cgo::draw::custom_cylinder_alpha& cyl){
return customCylinder3fv(cyl.vertex1, cyl.vertex2, cyl.radius, cyl.color1,
cyl.color2, cyl.cap1, cyl.cap2, cyl.color1[3], cyl.color
2[3]);
}
int CRay::customCylinder3fv(const float* v1, const float* v2, float r,
const float* c1, const float* c2, const int cap1, const int cap2)
{
return customCylinder3fv(
v1, v2, r, c1, c2, cap1, cap2, 1.f - Trans, 1.f - Trans);
}
int CRay::customCylinder3fv(const float *v1, const float *v2, float r, int CRay::customCylinder3fv(const float *v1, const float *v2, float r,
const float *c1, const float *c2, int cap1, int cap2) const float *c1, const float *c2, const int cap1,
const int cap2, const float alpha1, const float alph
a2)
{ {
CRay * I = this; CRay * I = this;
CPrimitive *p; CPrimitive *p;
int ok = true; int ok = true;
float *vv; float *vv;
VLACacheCheck(I->G, I->Primitive, CPrimitive, I->NPrimitive, 0, cCache_ray_pri mitive); VLACacheCheck(I->G, I->Primitive, CPrimitive, I->NPrimitive, 0, cCache_ray_pri mitive);
CHECKOK(ok, I->Primitive); CHECKOK(ok, I->Primitive);
if (!ok) if (!ok)
return false; return false;
skipping to change at line 7001 skipping to change at line 7015
vv = p->c1; vv = p->c1;
(*vv++) = (*c1++); (*vv++) = (*c1++);
(*vv++) = (*c1++); (*vv++) = (*c1++);
(*vv++) = (*c1++); (*vv++) = (*c1++);
vv = p->c2; vv = p->c2;
(*vv++) = (*c2++); (*vv++) = (*c2++);
(*vv++) = (*c2++); (*vv++) = (*c2++);
(*vv++) = (*c2++); (*vv++) = (*c2++);
vv = p->ic; vv = p->ic;
p->trans = 1.0f - alpha1;
{ {
float *v; float *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++);
} }
I->NPrimitive++; I->NPrimitive++;
skipping to change at line 7493 skipping to change at line 7510
return true; return true;
} }
/*========================================================================*/ /*========================================================================*/
CRay *RayNew(PyMOLGlobals * G, int antialias) CRay *RayNew(PyMOLGlobals * G, int antialias)
{ {
unsigned int test; unsigned int test;
unsigned char *testPtr; unsigned char *testPtr;
int a; int a;
OOAlloc(I->G, CRay); OOCalloc(I->G, CRay);
I->G = G; I->G = G;
test = 0xFF000000; test = 0xFF000000;
testPtr = (unsigned char *) &test; testPtr = (unsigned char *) &test;
I->BigEndian = (*testPtr) & 0x01; I->BigEndian = (*testPtr) & 0x01;
I->Trans = 0.0F; I->Trans = 0.0F;
I->Wobble = 0; I->Wobble = 0;
I->TTTFlag = false; I->TTTFlag = false;
zero3f(I->WobbleParam); zero3f(I->WobbleParam);
PRINTFB(I->G, FB_Ray, FB_Blather) PRINTFB(I->G, FB_Ray, FB_Blather)
" RayNew: BigEndian = %d\n", I->BigEndian ENDFB(I->G); " RayNew: BigEndian = %d\n", I->BigEndian ENDFB(I->G);
skipping to change at line 7532 skipping to change at line 7549
} }
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
 End of changes. 22 change blocks. 
43 lines changed or deleted 63 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)