RepDihedral.cpp (pymol-v2.1.0.tar.bz2) | : | RepDihedral.cpp (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 60 | skipping to change at line 60 | |||
{ | { | |||
if (I->shaderCGO){ | if (I->shaderCGO){ | |||
CGOFree(I->shaderCGO); | CGOFree(I->shaderCGO); | |||
I->shaderCGO = 0; | I->shaderCGO = 0; | |||
} | } | |||
VLAFreeP(I->V); | VLAFreeP(I->V); | |||
RepPurge(&I->R); | RepPurge(&I->R); | |||
OOFreeP(I); | OOFreeP(I); | |||
} | } | |||
static int RepDihedralCGOGenerate(RepDihedral * I, RenderInfo * info) | ||||
{ | ||||
PyMOLGlobals *G = I->R.G; | ||||
float *v = I->V; | ||||
int c = I->N; | ||||
float line_width; | ||||
int ok = true; | ||||
CGO *convertcgo = NULL; | ||||
short dash_as_cylinders = 0; | ||||
int color = | ||||
SettingGet_color(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dihedral_color); | ||||
I->linewidth = line_width = | ||||
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width); | ||||
I->radius = | ||||
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_radius); | ||||
line_width = SceneGetDynamicLineWidth(info, line_width); | ||||
dash_as_cylinders = SettingGetGlobal_b(G, cSetting_render_as_cylinders) && Set | ||||
tingGetGlobal_b(G, cSetting_dash_as_cylinders); | ||||
if (ok) | ||||
ok &= CGOSpecial(I->shaderCGO, LINEWIDTH_DYNAMIC_WITH_SCALE_DASH); | ||||
if (ok) | ||||
ok &= CGOResetNormal(I->shaderCGO, true); | ||||
if (ok){ | ||||
if(color >= 0){ | ||||
ok &= CGOColorv(I->shaderCGO, ColorGet(G, color)); | ||||
} else if (I->Obj && I->Obj->Color >= 0){ | ||||
ok &= CGOColorv(I->shaderCGO, ColorGet(G, I->Obj->Color)); | ||||
} | ||||
} | ||||
v = I->V; | ||||
c = I->N; | ||||
if (dash_as_cylinders){ | ||||
float *origin = NULL, axis[3]; | ||||
while(ok && c > 0) { | ||||
origin = v; | ||||
v += 3; | ||||
axis[0] = v[0] - origin[0]; | ||||
axis[1] = v[1] - origin[1]; | ||||
axis[2] = v[2] - origin[2]; | ||||
v += 3; | ||||
ok &= (bool)I->shaderCGO->add<cgo::draw::shadercylinder>(origin, axis, 1.f | ||||
, 15); | ||||
c -= 2; | ||||
} | ||||
} else { | ||||
if (ok) | ||||
ok &= CGOBegin(I->shaderCGO, GL_LINES); | ||||
while(ok && c > 0) { | ||||
ok &= CGOVertexv(I->shaderCGO, v); | ||||
v += 3; | ||||
if (ok) | ||||
ok &= CGOVertexv(I->shaderCGO, v); | ||||
v += 3; | ||||
c -= 2; | ||||
} | ||||
if (ok) | ||||
ok &= CGOEnd(I->shaderCGO); | ||||
} | ||||
if (ok) | ||||
ok &= CGOStop(I->shaderCGO); | ||||
if (ok) | ||||
convertcgo = CGOCombineBeginEnd(I->shaderCGO, 0); | ||||
CHECKOK(ok, convertcgo); | ||||
CGOFree(I->shaderCGO); | ||||
I->shaderCGO = convertcgo; | ||||
convertcgo = NULL; | ||||
if (ok){ | ||||
if (dash_as_cylinders){ | ||||
CGO *tmpCGO = CGONew(G); | ||||
if (ok) ok &= CGOEnable(tmpCGO, GL_CYLINDER_SHADER); | ||||
if (ok) ok &= CGOSpecial(tmpCGO, CYLINDER_WIDTH_FOR_DISTANCES); | ||||
convertcgo = CGOConvertShaderCylindersToCylinderShader(I->shaderCGO, tmpCG | ||||
O); | ||||
if (ok) ok &= CGOEnable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST); | ||||
if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo); | ||||
if (ok) ok &= CGODisable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST); | ||||
if (ok) ok &= CGODisable(tmpCGO, GL_CYLINDER_SHADER); | ||||
if (ok) ok &= CGOStop(tmpCGO); | ||||
CGOFreeWithoutVBOs(convertcgo); | ||||
convertcgo = tmpCGO; | ||||
} else { | ||||
CGO *tmpCGO = CGONew(G); | ||||
if (ok) ok &= CGOEnable(tmpCGO, GL_DEFAULT_SHADER); | ||||
if (ok) ok &= CGODisable(tmpCGO, CGO_GL_LIGHTING); | ||||
convertcgo = CGOOptimizeToVBONotIndexedNoShader(I->shaderCGO, 0); | ||||
if (ok) ok &= CGOEnable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST); | ||||
if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo); | ||||
if (ok) ok &= CGODisable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST); | ||||
if (ok) ok &= CGODisable(tmpCGO, GL_DEFAULT_SHADER); | ||||
if (ok) ok &= CGOStop(tmpCGO); | ||||
CGOFreeWithoutVBOs(convertcgo); | ||||
convertcgo = tmpCGO; | ||||
} | ||||
convertcgo->use_shader = true; | ||||
} | ||||
if (convertcgo){ | ||||
CGOFree(I->shaderCGO); | ||||
I->shaderCGO = convertcgo; | ||||
} | ||||
return ok; | ||||
} | ||||
static void RepDihedralRender(RepDihedral * I, RenderInfo * info) | static void RepDihedralRender(RepDihedral * 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; | |||
float *vc; | const float *vc; | |||
float line_width; | float line_width; | |||
int round_ends; | int round_ends; | |||
int ok = true; | int ok = true; | |||
int color = | int color = | |||
SettingGet_color(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dihedral_color); | SettingGet_color(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dihedral_color); | |||
float dash_transparency = | ||||
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_transparency); | ||||
bool t_mode_3 = | ||||
SettingGet_i(G, NULL, I->ds->Obj->Obj.Setting, cSetting_transparency_mode) = | ||||
= 3; | ||||
short dash_transparency_enabled; | ||||
if(color < 0) | ||||
color = I->Obj->Color; | ||||
dash_transparency = (dash_transparency < 0.f ? 0.f : (dash_transparency > 1.f | ||||
? 1.f : dash_transparency)); | ||||
dash_transparency_enabled = (dash_transparency > 0.f); | ||||
if (!(ray || pick) && (!info->pass || (info->pass > 0) == dash_transparency_en | ||||
abled)) | ||||
return; | ||||
I->linewidth = line_width = | I->linewidth = line_width = | |||
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width); | SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width); | |||
I->radius = | I->radius = | |||
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_radius); | SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_radius); | |||
round_ends = | round_ends = | |||
SettingGet_b(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_round_ends); | SettingGet_b(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_round_ends); | |||
line_width = SceneGetDynamicLineWidth(info, line_width); | line_width = SceneGetDynamicLineWidth(info, line_width); | |||
if(ray) { | if(ray) { | |||
#ifndef _PYMOL_NO_RAY | ||||
float radius; | float radius; | |||
if (dash_transparency_enabled){ | ||||
ray->transparentf(dash_transparency); | ||||
} | ||||
if(I->radius == 0.0F) { | if(I->radius == 0.0F) { | |||
radius = ray->PixelRadius * line_width / 2.0F; | radius = ray->PixelRadius * line_width / 2.0F; | |||
} else { | } else { | |||
radius = I->radius; | radius = I->radius; | |||
} | } | |||
if(color < 0) | ||||
color = I->Obj->Color; | ||||
vc = ColorGet(G, color); | vc = ColorGet(G, color); | |||
v = I->V; | v = I->V; | |||
c = I->N; | c = I->N; | |||
while(ok && c > 0) { | while(ok && c > 0) { | |||
/* printf("%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f \n",v[3],v[4],v[5],v [6],v[7],v[8]); */ | /* printf("%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f \n",v[3],v[4],v[5],v [6],v[7],v[8]); */ | |||
if(round_ends) { | if(round_ends) { | |||
ok &= ray->sausage3fv(v, v + 3, radius, vc, vc); | ok &= ray->sausage3fv(v, v + 3, radius, vc, vc); | |||
} else { | } else { | |||
ok &= ray->customCylinder3fv(v, v + 3, radius, vc, vc, cCylCapFlat, cCyl CapFlat); | ok &= ray->customCylinder3fv(v, v + 3, radius, vc, vc, cCylCapFlat, cCyl CapFlat); | |||
} | } | |||
v += 6; | v += 6; | |||
c -= 2; | c -= 2; | |||
} | } | |||
#endif | ||||
} else if(G->HaveGUI && G->ValidContext) { | } else if(G->HaveGUI && G->ValidContext) { | |||
if(pick) { | if(pick) { | |||
} else { | } else { | |||
short use_shader, generate_shader_cgo = 0, dash_as_cylinders = 0; | short use_shader, generate_shader_cgo = 0; | |||
use_shader = SettingGetGlobal_b(G, cSetting_dash_use_shader) & | use_shader = SettingGetGlobal_b(G, cSetting_dash_use_shader) & | |||
SettingGetGlobal_b(G, cSetting_use_shaders); | SettingGetGlobal_b(G, cSetting_use_shaders); | |||
dash_as_cylinders = SettingGetGlobal_b(G, cSetting_render_as_cylinders) && SettingGetGlobal_b(G, cSetting_dash_as_cylinders); | ||||
if (!use_shader && I->shaderCGO){ | if (!use_shader && I->shaderCGO){ | |||
CGOFree(I->shaderCGO); | CGOFree(I->shaderCGO); | |||
I->shaderCGO = 0; | I->shaderCGO = 0; | |||
} | } | |||
if (use_shader){ | if (use_shader){ | |||
if (!I->shaderCGO){ | if (!I->shaderCGO){ | |||
I->shaderCGO = CGONew(G); | I->shaderCGO = CGONew(G); | |||
CHECKOK(ok, I->shaderCGO); | CHECKOK(ok, I->shaderCGO); | |||
if (ok) | if (ok) | |||
I->shaderCGO->use_shader = true; | I->shaderCGO->use_shader = true; | |||
generate_shader_cgo = 1; | generate_shader_cgo = 1; | |||
} else { | if (dash_transparency_enabled){ | |||
CShaderPrg *shaderPrg; | CGOAlpha(I->shaderCGO, 1.f-dash_transparency); | |||
if (dash_as_cylinders){ | ||||
float pixel_scale_value = SettingGetGlobal_f(G, cSetting_ray_pixel_sc | ||||
ale); | ||||
if(pixel_scale_value < 0) | ||||
pixel_scale_value = 1.0F; | ||||
shaderPrg = CShaderPrg_Enable_CylinderShader(G); | ||||
if(I->radius == 0.0F) { | ||||
CShaderPrg_Set1f(shaderPrg, "uni_radius", info->vertex_scale * pixe | ||||
l_scale_value * line_width/ 2.f); | ||||
} else { | ||||
CShaderPrg_Set1f(shaderPrg, "uni_radius", I->radius); | ||||
} | ||||
if (!round_ends){ | ||||
CShaderPrg_Set1f(shaderPrg, "no_flat_caps", 0.f); | ||||
} | ||||
} else { | ||||
shaderPrg = CShaderPrg_Enable_DefaultShader(G); | ||||
CShaderPrg_SetLightingEnabled(shaderPrg, 0); | ||||
} | } | |||
if (!shaderPrg) return; | ok &= RepDihedralCGOGenerate(I, info); | |||
} else { | ||||
CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); | CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); | |||
CShaderPrg_Disable(shaderPrg); | ||||
return; | return; | |||
} | } | |||
} | } | |||
#ifndef PURE_OPENGL_ES_2 | ||||
if (generate_shader_cgo){ | if (!generate_shader_cgo) { | |||
if (ok) | ||||
ok &= CGOLinewidthSpecial(I->shaderCGO, LINEWIDTH_DYNAMIC_WITH_SCALE_DA | ||||
SH); | ||||
if (ok) | ||||
ok &= CGOResetNormal(I->shaderCGO, true); | ||||
} else { | ||||
if(info->width_scale_flag) { | if(info->width_scale_flag) { | |||
glLineWidth(line_width * info->width_scale); | glLineWidth(line_width * info->width_scale); | |||
} else { | } else { | |||
glLineWidth(line_width); | glLineWidth(line_width); | |||
} | } | |||
SceneResetNormal(G, true); | SceneResetNormal(G, true); | |||
} | ||||
if (generate_shader_cgo){ | ||||
if (ok){ | ||||
if(color >= 0){ | ||||
ok &= CGOColorv(I->shaderCGO, ColorGet(G, color)); | ||||
} else if (I->Obj && I->Obj->Color >= 0){ | ||||
ok &= CGOColorv(I->shaderCGO, ColorGet(G, I->Obj->Color)); | ||||
} | ||||
} | ||||
v = I->V; | ||||
c = I->N; | ||||
if (dash_as_cylinders){ | ||||
float *origin = NULL, axis[3]; | ||||
while(ok && c > 0) { | ||||
origin = v; | ||||
v += 3; | ||||
axis[0] = v[0] - origin[0]; | ||||
axis[1] = v[1] - origin[1]; | ||||
axis[2] = v[2] - origin[2]; | ||||
v += 3; | ||||
ok &= CGOShaderCylinder(I->shaderCGO, origin, axis, 1.f, 15); | ||||
c -= 2; | ||||
} | ||||
} else { | ||||
if (ok) | ||||
ok &= CGOBegin(I->shaderCGO, GL_LINES); | ||||
while(ok && c > 0) { | ||||
ok &= CGOVertexv(I->shaderCGO, v); | ||||
v += 3; | ||||
if (ok) | ||||
ok &= CGOVertexv(I->shaderCGO, v); | ||||
v += 3; | ||||
c -= 2; | ||||
} | ||||
if (ok) | ||||
ok &= CGOEnd(I->shaderCGO); | ||||
} | ||||
} else { | ||||
if(color >= 0){ | if(color >= 0){ | |||
glColor3fv(ColorGet(G, color)); | if (dash_transparency_enabled){ | |||
const float *col = ColorGet(G, color); | ||||
glColor4f(col[0], col[1], col[2], 1.f-dash_transparency); | ||||
} else { | ||||
glColor3fv(ColorGet(G, color)); | ||||
} | ||||
} else if (dash_transparency_enabled){ | ||||
float col[4]; | ||||
copy3f(ColorGet(I->Obj->G, I->Obj->Color), col); | ||||
col[3] = 1.f-dash_transparency; | ||||
glColor4fv(col); | ||||
} | } | |||
v = I->V; | v = I->V; | |||
c = I->N; | c = I->N; | |||
if (dash_transparency_enabled && !t_mode_3) | ||||
glDisable(GL_DEPTH_TEST); | ||||
if(!info->line_lighting) | if(!info->line_lighting) | |||
glDisable(GL_LIGHTING); | glDisable(GL_LIGHTING); | |||
glBegin(GL_LINES); | glBegin(GL_LINES); | |||
while(c > 0) { | while(c > 0) { | |||
glVertex3fv(v); | glVertex3fv(v); | |||
v += 3; | v += 3; | |||
glVertex3fv(v); | glVertex3fv(v); | |||
v += 3; | v += 3; | |||
c -= 2; | c -= 2; | |||
} | } | |||
glEnd(); | glEnd(); | |||
glEnable(GL_LIGHTING); | glEnable(GL_LIGHTING); | |||
if (dash_transparency_enabled && !t_mode_3) | ||||
glEnable(GL_DEPTH_TEST); | ||||
} | } | |||
#endif | ||||
if (use_shader) { | if (use_shader) { | |||
if (generate_shader_cgo){ | ||||
CGO *convertcgo = NULL; | ||||
if (ok) | ||||
ok &= CGOStop(I->shaderCGO); | ||||
if (ok) | ||||
convertcgo = CGOCombineBeginEnd(I->shaderCGO, 0); | ||||
CHECKOK(ok, convertcgo); | ||||
CGOFree(I->shaderCGO); | ||||
I->shaderCGO = convertcgo; | ||||
convertcgo = NULL; | ||||
if (ok){ | ||||
if (dash_as_cylinders){ | ||||
convertcgo = CGOOptimizeGLSLCylindersToVBOIndexed(I->shaderCGO, 0); | ||||
} else { | ||||
convertcgo = CGOOptimizeToVBONotIndexed(I->shaderCGO, 0); | ||||
} | ||||
CHECKOK(ok, convertcgo); | ||||
} | ||||
if (convertcgo){ | ||||
CGOFree(I->shaderCGO); | ||||
I->shaderCGO = convertcgo; | ||||
} | ||||
} | ||||
if (ok) { | if (ok) { | |||
CShaderPrg *shaderPrg; | ||||
if (dash_as_cylinders){ | ||||
float pixel_scale_value = SettingGetGlobal_f(G, cSetting_ray_pixel_sc | ||||
ale); | ||||
if(pixel_scale_value < 0) | ||||
pixel_scale_value = 1.0F; | ||||
shaderPrg = CShaderPrg_Enable_CylinderShader(G); | ||||
if(I->radius == 0.0F) { | ||||
CShaderPrg_Set1f(shaderPrg, "uni_radius", info->vertex_scale * pixe | ||||
l_scale_value * line_width/ 2.f); | ||||
} else { | ||||
CShaderPrg_Set1f(shaderPrg, "uni_radius", I->radius); | ||||
} | ||||
if (!round_ends){ | ||||
CShaderPrg_Set1f(shaderPrg, "no_flat_caps", 0.f); | ||||
} | ||||
} else { | ||||
shaderPrg = CShaderPrg_Enable_DefaultShader(G); | ||||
CShaderPrg_SetLightingEnabled(shaderPrg, 0); | ||||
} | ||||
CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); | CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); | |||
CShaderPrg_Disable(shaderPrg); | ||||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
if (!ok){ | if (!ok){ | |||
CGOFree(I->shaderCGO); | CGOFree(I->shaderCGO); | |||
I->ds->Rep[cRepDihedral] = NULL; | I->ds->Rep[cRepDihedral] = NULL; | |||
RepDihedralFree(I); | RepDihedralFree(I); | |||
} | } | |||
} | } | |||
skipping to change at line 328 | skipping to change at line 358 | |||
I->shaderCGO = 0; | I->shaderCGO = 0; | |||
I->N = 0; | I->N = 0; | |||
I->V = NULL; | I->V = NULL; | |||
I->R.P = NULL; | I->R.P = NULL; | |||
I->Obj = (CObject *) ds->Obj; | I->Obj = (CObject *) ds->Obj; | |||
I->ds = ds; | I->ds = ds; | |||
n = 0; | n = 0; | |||
if(ds->NDihedralIndex) { | if(ds->NDihedralIndex) { | |||
float *v1, *v2, *v3, *v4, *v5, *v6; | float *v1, *v2, *v3, *v4, *v5; | |||
float d12[3], d32[3], d43[3], n12[3], n32[3], n43[3]; | float d12[3], d32[3], d43[3], n12[3], n32[3], n43[3]; | |||
float p12[3], p43[3], np12[3], np43[3], v12[3], v43[3]; | float p12[3], p43[3], np12[3], np43[3], v12[3], v43[3]; | |||
float s12[3], s43[3]; | float s12[3], s43[3]; | |||
float a32[3]; | float a32[3]; | |||
float l1, l2; | float l1, l2; | |||
float d3[3], n1[3], n3[3], x[3], y[3]; | float d3[3], n1[3], n3[3], x[3], y[3]; | |||
float radius, length, angle, phase, pos; | float radius, length, angle, phase, pos; | |||
float dihedral_size = | float dihedral_size = | |||
SettingGet_f(G, NULL, ds->Obj->Obj.Setting, cSetting_dihedral_size); | SettingGet_f(G, NULL, ds->Obj->Obj.Setting, cSetting_dihedral_size); | |||
I->V = VLAlloc(float, ds->NDihedralIndex * 10); | I->V = VLAlloc(float, ds->NDihedralIndex * 10); | |||
CHECKOK(ok, I->V); | CHECKOK(ok, I->V); | |||
for(a = 0; ok && a < ds->NDihedralIndex; a = a + 6) { | for(a = 0; ok && a < ds->NDihedralIndex; a = a + 6) { | |||
v1 = ds->DihedralCoord + 3 * a; | v1 = ds->DihedralCoord + 3 * a; | |||
v2 = v1 + 3; | v2 = v1 + 3; | |||
v3 = v1 + 6; | v3 = v1 + 6; | |||
v4 = v1 + 9; | v4 = v1 + 9; | |||
v5 = v1 + 12; | v5 = v1 + 12; | |||
v6 = v1 + 15; | ||||
subtract3f(v1, v2, d12); | subtract3f(v1, v2, d12); | |||
subtract3f(v3, v2, d32); | subtract3f(v3, v2, d32); | |||
subtract3f(v4, v3, d43); | subtract3f(v4, v3, d43); | |||
normalize23f(d12, n12); | normalize23f(d12, n12); | |||
normalize23f(d32, n32); | normalize23f(d32, n32); | |||
normalize23f(d43, n43); | normalize23f(d43, n43); | |||
remove_component3f(d12, n32, p12); | remove_component3f(d12, n32, p12); | |||
End of changes. 24 change blocks. | ||||
124 lines changed or deleted | 154 lines changed or added |