"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer2/RepDot.cpp" between
pymol-v2.1.0.tar.bz2 and pymol-open-source-2.2.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.

RepDot.cpp  (pymol-v2.1.0.tar.bz2):RepDot.cpp  (pymol-open-source-2.2.0)
skipping to change at line 37 skipping to change at line 37
#include"Sphere.h" #include"Sphere.h"
#include"Map.h" #include"Map.h"
#include"Setting.h" #include"Setting.h"
#include"main.h" #include"main.h"
#include"ObjectMolecule.h" #include"ObjectMolecule.h"
#include"Scene.h" #include"Scene.h"
#include"ShaderMgr.h" #include"ShaderMgr.h"
#include"CGO.h" #include"CGO.h"
void RepDotFree(RepDot * I); void RepDotFree(RepDot * I);
static void RepDotRender(RepDot * I, RenderInfo * info);
void RepDotInit(void) void RepDotInit(void)
{ {
} }
void RepDotFree(RepDot * I) void RepDotFree(RepDot * I)
{ {
if (I->shaderCGO){ if (I->shaderCGO){
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
I->shaderCGO = 0; I->shaderCGO = 0;
skipping to change at line 58 skipping to change at line 59
FreeP(I->VC); FreeP(I->VC);
FreeP(I->V); FreeP(I->V);
FreeP(I->T); FreeP(I->T);
FreeP(I->F); FreeP(I->F);
FreeP(I->VN); FreeP(I->VN);
FreeP(I->A); FreeP(I->A);
FreeP(I->Atom); FreeP(I->Atom);
OOFreeP(I); OOFreeP(I);
} }
static int RepDotCGOGenerate(RepDot * I, RenderInfo * info)
{
PyMOLGlobals *G = I->R.G;
float *v = I->V;
int c = I->N;
int cc = 0;
int ok = true;
CGO *cgo = NULL;
int normals =
SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_dot_normals);
short dot_as_spheres = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cS
etting_dot_as_spheres);
cgo = CGONew(G);
CHECKOK(ok, cgo);
if (dot_as_spheres){
while(ok && c--) {
if(!cc) { /* load up the current vertex color */
cc = (int) (*(v++));
ok &= CGOColorv(cgo, v);
v += 3;
}
if(ok && normals)
ok &= CGONormalv(cgo, v);
v += 3;
if (ok)
ok &= CGOSphere(cgo, v, 1.f);
v += 3;
cc--;
}
} else {
if (ok)
ok &= CGOBegin(cgo, GL_POINTS);
while(ok && c--) {
if(!cc) { /* load up the current vertex color */
cc = (int) (*(v++));
ok &= CGOColorv(cgo, v);
v += 3;
}
if(normals)
CGONormalv(cgo, v);
v += 3;
if (ok)
ok &= CGOVertexv(cgo, v);
v += 3;
cc--;
}
if (ok)
ok &= CGOEnd(cgo);
}
if (ok)
ok &= CGOStop(cgo);
if (ok) {
if (dot_as_spheres){
CGO *tmpCGO = CGONew(G), *tmp2CGO = NULL;
if (ok) ok &= CGOEnable(tmpCGO, GL_SPHERE_SHADER);
if (ok) ok &= CGOEnable(tmpCGO, GL_DOT_LIGHTING);
if (ok) ok &= CGOSpecial(tmpCGO, DOT_WIDTH_FOR_DOT_SPHERES);
tmp2CGO = CGOOptimizeSpheresToVBONonIndexedNoShader(cgo,
CGO_BOUNDING_BOX_SZ + fsizeof<cgo::draw::sphere_buffers>() + 2);
if (ok)
ok &= CGOAppendNoStop(tmpCGO, tmp2CGO);
CGOFreeWithoutVBOs(tmp2CGO);
if (ok) ok &= CGODisable(tmpCGO, GL_SPHERE_SHADER);
if (ok) ok &= CGOStop(tmpCGO);
I->shaderCGO = tmpCGO;
} else {
CGO *convertcgo = CGOCombineBeginEnd(cgo, 0), *tmp2CGO = NULL;
CGO *tmpCGO = CGONew(G);
if (ok) ok &= CGOEnable(tmpCGO, GL_DEFAULT_SHADER);
if (ok) ok &= CGOEnable(tmpCGO, GL_DOT_LIGHTING);
if (ok) ok &= CGOSpecial(tmpCGO, DOT_WIDTH_FOR_DOTS);
CHECKOK(ok, convertcgo);
if (ok)
tmp2CGO = CGOOptimizeToVBONotIndexedNoShader(convertcgo, CGO_BOUNDING_BOX
_SZ + I->N * 3 + 7);
CHECKOK(ok, tmp2CGO);
if (ok)
ok &= CGOAppendNoStop(tmpCGO, tmp2CGO);
CGOFreeWithoutVBOs(tmp2CGO);
CGOFree(convertcgo);
if (ok) ok &= CGODisable(tmpCGO, GL_DEFAULT_SHADER);
if (ok) ok &= CGOStop(tmpCGO);
I->shaderCGO = tmpCGO;
}
}
if (ok){
I->shaderCGO->use_shader = true;
I->shaderCGO_as_spheres = dot_as_spheres;
}
CGOFree(cgo);
/* now that the shaderCGO is created, we can just call RepDotRender to render
it */
if (ok)
RepDotRender(I, info);
return ok;
}
static void RepDotRender(RepDot * I, RenderInfo * info) static void RepDotRender(RepDot * I, RenderInfo * info)
{ {
CRay *ray = info->ray; CRay *ray = info->ray;
Picking **pick = info->pick; Picking **pick = info->pick;
PyMOLGlobals *G = I->R.G; PyMOLGlobals *G = I->R.G;
float *v = I->V; float *v = I->V;
int c = I->N; int c = I->N;
int cc = 0; int cc = 0;
int ok = true; int ok = true;
if(ray) { if(ray) {
#ifndef _PYMOL_NO_RAY
float radius; float radius;
if(I->dotSize <= 0.0F) { if(I->dotSize <= 0.0F) {
radius = ray->PixelRadius * I->Width / 1.4142F; radius = ray->PixelRadius * I->Width / 1.4142F;
} else { } else {
radius = I->dotSize; radius = I->dotSize;
} }
while(ok && c--) { while(ok && c--) {
if(!cc) { /* load up the current vertex color */ if(!cc) { /* load up the current vertex color */
cc = (int) (*(v++)); cc = (int) (*(v++));
ray->color3fv(v); ray->color3fv(v);
v += 3; v += 3;
} }
v += 3; v += 3;
ok &= ray->sphere3fv(v, radius); ok &= ray->sphere3fv(v, radius);
v += 3; v += 3;
cc--; cc--;
} }
#endif
} else if(G->HaveGUI && G->ValidContext) { } else if(G->HaveGUI && G->ValidContext) {
if(pick) { if(pick) {
} else { /* else not pick, i.e., when rendering */ } else { /* else not pick, i.e., when rendering */
short use_shader, generate_shader_cgo = 0; short use_shader, generate_shader_cgo = 0;
int normals = int normals =
SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_dot_normal s); SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_dot_normal s);
short dot_as_spheres = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting , cSetting_dot_as_spheres); short dot_as_spheres = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting , cSetting_dot_as_spheres);
use_shader = SettingGetGlobal_b(G, cSetting_dot_use_shader) & use_shader = SettingGetGlobal_b(G, cSetting_dot_use_shader) &
SettingGetGlobal_b(G, cSetting_use_shaders); SettingGetGlobal_b(G, cSetting_use_shaders);
if (I->shaderCGO && ((!use_shader || CGOCheckWhetherToFree(G, I->shaderCGO )) || if (I->shaderCGO && ((!use_shader || CGOCheckWhetherToFree(G, I->shaderCGO )) ||
I->shaderCGO_as_spheres!= dot_as_spheres)){ I->shaderCGO_as_spheres!= dot_as_spheres)){
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
I->shaderCGO = 0; I->shaderCGO = 0;
} }
if (use_shader){ if (use_shader){
if (!I->shaderCGO){ if (!I->shaderCGO){
generate_shader_cgo = 1; generate_shader_cgo = 1;
ok &= RepDotCGOGenerate(I, info);
} else { } else {
CShaderPrg *shaderPrg; const float *color;
float *color;
color = ColorGet(G, I->R.obj->Color); color = ColorGet(G, I->R.obj->Color);
CGORenderGL(I->shaderCGO, color, NULL, NULL, info, &I->R);
I->shaderCGO->enable_shaders = false;
if (dot_as_spheres){
float radius;
if(I->dotSize <= 0.0F) {
if(info->width_scale_flag)
radius = I->Width * info->width_scale * info->vertex_scale / 1.41
42F;
else
radius = I->Width * info->vertex_scale;
} else {
radius = I->dotSize;
}
shaderPrg = CShaderPrg_Enable_DefaultSphereShader(G);
CShaderPrg_Set1f(shaderPrg, "sphere_size_scale", fabs(radius));
CGORenderGL(I->shaderCGO, color, NULL, NULL, info, &I->R);
CShaderPrg_Disable(shaderPrg);
} else {
shaderPrg = CShaderPrg_Enable_DefaultShader(G);
if (!shaderPrg) return;
CShaderPrg_SetLightingEnabled(shaderPrg, 0);
SceneResetNormalUseShaderAttribute(G, 0, true, CShaderPrg_GetAttribLo
cation(shaderPrg, "a_Normal"));
CGORenderGL(I->shaderCGO, color, NULL, NULL, info, &I->R);
CShaderPrg_Disable(shaderPrg);
}
return; /* should not do any other rendering after shaderCGO has return; /* should not do any other rendering after shaderCGO has
been rendered */ been rendered */
} }
} }
if (generate_shader_cgo){ if (!generate_shader_cgo) {
CGO *cgo = CGONew(G);
CHECKOK(ok, cgo);
if (ok)
I->shaderCGO = CGONew(G);
CHECKOK(ok, I->shaderCGO);
if (ok)
CGOSetUseShader(I->shaderCGO, true);
if(ok && !normals)
CGOResetNormal(I->shaderCGO, true);
if (dot_as_spheres){
while(ok && c--) {
if(!cc) { /* load up the current vertex color */
cc = (int) (*(v++));
ok &= CGOColorv(cgo, v);
v += 3;
}
if(ok && normals)
ok &= CGONormalv(cgo, v);
v += 3;
if (ok)
ok &= CGOSphere(cgo, v, 1.f);
v += 3;
cc--;
}
} else {
if (ok)
ok &= CGOLinewidthSpecial(I->shaderCGO, POINTSIZE_DYNAMIC_DOT_WIDTH);
if (ok)
ok &= CGOBegin(cgo, GL_POINTS);
while(ok && c--) {
if(!cc) { /* load up the current vertex color */
cc = (int) (*(v++));
ok &= CGOColorv(cgo, v);
v += 3;
}
/* if(normals) // NORMALS do not get set for points
CGONormalv(cgo, v);*/
v += 3;
if (ok)
ok &= CGOVertexv(cgo, v);
v += 3;
cc--;
}
if (ok)
ok &= CGOEnd(cgo);
}
if (ok)
ok &= CGOStop(cgo);
if (ok) {
if (dot_as_spheres){
I->shaderCGO = CGOOptimizeSpheresToVBONonIndexed(cgo, CGO_BOUNDING_BO
X_SZ + CGO_DRAW_SPHERE_BUFFERS_SZ);
CHECKOK(ok, I->shaderCGO);
} else {
CGO *convertcgo = CGOCombineBeginEnd(cgo, 0), *tmpCGO = NULL;
CHECKOK(ok, convertcgo);
if (ok)
tmpCGO = CGOOptimizeToVBONotIndexed(convertcgo, CGO_BOUNDING_BOX_SZ
+ I->N * 3 + 7);
CHECKOK(ok, tmpCGO);
if (ok)
ok &= CGOAppend(I->shaderCGO, tmpCGO);
CGOFreeWithoutVBOs(tmpCGO);
CGOFree(convertcgo);
}
if (ok)
ok &= CGOStop(I->shaderCGO);
}
if (ok){
I->shaderCGO->use_shader = true;
I->shaderCGO_as_spheres = dot_as_spheres;
}
CGOFree(cgo);
/* now that the shaderCGO is created, we can just call RepDotRender to re
nder it */
if (ok)
RepDotRender(I, info);
} else {
if(!normals) if(!normals)
SceneResetNormal(G, true); SceneResetNormal(G, true);
int lighting = int lighting =
SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_dot_ligh ting); SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_dot_ligh ting);
if(!lighting) { if(!lighting) {
if(!info->line_lighting) if(!info->line_lighting)
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
} }
if(info->width_scale_flag) if(info->width_scale_flag)
skipping to change at line 255 skipping to change at line 258
} }
glEnd(); glEnd();
if(!lighting) if(!lighting)
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
} }
} }
} }
if (!ok){ if (!ok){
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
I->shaderCGO = NULL;
I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge); I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge);
I->R.cs->Active[cRepDot] = false; I->R.cs->Active[cRepDot] = false;
} }
} }
Rep *RepDotNew(CoordSet * cs, int state) Rep *RepDotNew(CoordSet * cs, int state)
{ {
return (RepDotDoNew(cs, cRepDotNormal, state)); return (RepDotDoNew(cs, cRepDotNormal, state));
} }
Rep *RepDotDoNew(CoordSet * cs, int mode, int state) Rep *RepDotDoNew(CoordSet * cs, int mode, int state)
{ {
/* this routine does double duty - generating the dot representation, /* this routine does double duty - generating the dot representation,
but also acting as our surface area computation routine. but also acting as our surface area computation routine.
Modes: cRepDotNormal,cRepDotAreaType Modes: cRepDotNormal,cRepDotAreaType
*/ */
PyMOLGlobals *G = cs->State.G; PyMOLGlobals *G = cs->State.G;
ObjectMolecule *obj; ObjectMolecule *obj;
int a, b, flag, h, k, l, i, j, c1; int a, b, flag, h, k, l, i, j, c1;
float *v, *v0, *vc, vdw, *vn; float *v, *v0, vdw, *vn;
const float *vc;
float *aa = NULL; float *aa = NULL;
int *tp = NULL; int *tp = NULL;
int *tf = NULL; int *tf = NULL;
float *countPtr = NULL; float *countPtr = NULL;
int colorCnt, lastColor; int colorCnt, lastColor;
Vector3f v1; Vector3f v1;
MapType *map = NULL; MapType *map = NULL;
SphereRec *sp = G->Sphere->Sphere[0]; SphereRec *sp = G->Sphere->Sphere[0];
int ds; int ds;
float max_vdw = MAX_VDW; float max_vdw = MAX_VDW;
 End of changes. 10 change blocks. 
110 lines changed or deleted 111 lines changed or added

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