RepCartoon.cpp (pymol-open-source-2.2.0) | : | RepCartoon.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 66 | skipping to change at line 66 | |||
Rep R; /* must be first! */ | Rep R; /* must be first! */ | |||
CGO *ray, *std, *preshader; | CGO *ray, *std, *preshader; | |||
char *LastVisib; | char *LastVisib; | |||
unsigned char renderWithShaders, hasTransparency; | unsigned char renderWithShaders, hasTransparency; | |||
} RepCartoon; | } RepCartoon; | |||
#include"ObjectMolecule.h" | #include"ObjectMolecule.h" | |||
#define ESCAPE_MAX 500 | #define ESCAPE_MAX 500 | |||
void RepCartoonFree(RepCartoon * I); | static | |||
void RepCartoonFree(RepCartoon * I) | void RepCartoonFree(RepCartoon * I) | |||
{ | { | |||
if (I->ray != I->preshader) | if (I->ray != I->preshader) | |||
CGOFree(I->preshader); | CGOFree(I->preshader); | |||
CGOFree(I->ray); | CGOFree(I->ray); | |||
CGOFree(I->std); | CGOFree(I->std); | |||
FreeP(I->LastVisib); | FreeP(I->LastVisib); | |||
RepPurge(&I->R); | RepPurge(&I->R); | |||
OOFreeP(I); | OOFreeP(I); | |||
} | } | |||
skipping to change at line 106 | skipping to change at line 105 | |||
} | } | |||
static int RepCartoonCGOGenerate(RepCartoon * I, RenderInfo * info) | static int RepCartoonCGOGenerate(RepCartoon * I, RenderInfo * info) | |||
{ | { | |||
PyMOLGlobals *G = I->R.G; | PyMOLGlobals *G = I->R.G; | |||
int ok = true; | int ok = true; | |||
int use_shaders, has_cylinders_to_optimize; | int use_shaders, has_cylinders_to_optimize; | |||
float alpha = 1.0F - SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSet ting_cartoon_transparency); | float alpha = 1.0F - SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSet ting_cartoon_transparency); | |||
auto hasAtomLevelAlpha = [](RepCartoon * I){ | ||||
for(CoordSetAtomIterator iter(I->R.cs); iter.next();){ | ||||
auto ai = iter.getAtomInfo(); | ||||
if(AtomSettingGetWD(I->R.G, ai, cSetting_cartoon_transparency, 0.0f)){ | ||||
return true; | ||||
} | ||||
} | ||||
return false; | ||||
}(I); | ||||
use_shaders = SettingGetGlobal_b(G, cSetting_use_shaders) && SettingGetGlobal_ b(G, cSetting_cartoon_use_shader); | use_shaders = SettingGetGlobal_b(G, cSetting_use_shaders) && SettingGetGlobal_ b(G, cSetting_cartoon_use_shader); | |||
has_cylinders_to_optimize = G->ShaderMgr->Get_CylinderShader(info->pass, 0) && | has_cylinders_to_optimize = G->ShaderMgr->Get_CylinderShader(info->pass, 0) && | |||
SettingGetGlobal_i(G, cSetting_cartoon_nucleic_aci d_as_cylinders) && | SettingGetGlobal_i(G, cSetting_cartoon_nucleic_aci d_as_cylinders) && | |||
SettingGetGlobal_b(G, cSetting_render_as_cylinders ) && | SettingGetGlobal_b(G, cSetting_render_as_cylinders ) && | |||
CGOHasCylinderOperations(I->preshader); | CGOHasCylinderOperations(I->preshader); | |||
if (I->std && | if (I->std && | |||
(use_shaders ^ I->renderWithShaders)){ | (use_shaders ^ I->renderWithShaders)){ | |||
// if renderWithShaders doesn't match use_shader, clear CGO and re-generate | // if renderWithShaders doesn't match use_shader, clear CGO and re-generate | |||
CGOFree(I->std); | CGOFree(I->std); | |||
I->std = 0; | I->std = 0; | |||
} | } | |||
I->hasTransparency = 0; | I->hasTransparency = 0; | |||
if (use_shaders){ | if (use_shaders){ | |||
CGO *convertcgo = NULL, *tmpCGO = NULL, *tmp2CGO = NULL; | CGO *convertcgo = NULL, *tmpCGO = NULL, *tmp2CGO = NULL; | |||
if ((alpha < 1.f) && (SettingGetGlobal_i(G, cSetting_transparency_mode) != 3 | if (((alpha < 1.f) || hasAtomLevelAlpha) && | |||
)){ | (SettingGetGlobal_i(G, cSetting_transparency_mode) != 3)){ | |||
// some transparency | // some transparency | |||
const float *color; | const float *color; | |||
float colorWithA[4]; | float colorWithA[4]; | |||
CGO *convertcgo2; | CGO *convertcgo2; | |||
convertcgo2 = CGOSimplify(I->preshader, 0) ; | convertcgo2 = CGOSimplify(I->preshader, 0) ; | |||
convertcgo = CGOCombineBeginEnd(convertcgo2, 0); | convertcgo = CGOCombineBeginEnd(convertcgo2, 0); | |||
CGOFree(convertcgo2); | CGOFree(convertcgo2); | |||
CHECKOK(ok, convertcgo); | CHECKOK(ok, convertcgo); | |||
color = ColorGet(G, I->R.obj->Color); | color = ColorGet(G, I->R.obj->Color); | |||
copy3f(color, colorWithA); | copy3f(color, colorWithA); | |||
skipping to change at line 209 | skipping to change at line 218 | |||
CHECKOK(ok, tmpCGO); | CHECKOK(ok, tmpCGO); | |||
CGOFree(leftOverCGOCombined); | CGOFree(leftOverCGOCombined); | |||
if (ok) | if (ok) | |||
ok &= CGOAppend(convertcgo, tmpCGO); | ok &= CGOAppend(convertcgo, tmpCGO); | |||
CGOFreeWithoutVBOs(tmpCGO); | CGOFreeWithoutVBOs(tmpCGO); | |||
tmpCGO = NULL; | tmpCGO = NULL; | |||
I->std = CGOAddTwoSidedBackfaceSpecialOps(G, convertcgo); | I->std = CGOAddTwoSidedBackfaceSpecialOps(G, convertcgo); | |||
} | } | |||
} else { | } else { | |||
if (ok){ | if (ok){ | |||
if (alpha < 1.f){ | auto simplifiedCGO = CGOSimplify(I->preshader, 0); | |||
CGO *tmpCGO = NULL; | if (alpha < 1.f || hasAtomLevelAlpha){ | |||
tmpCGO = CGOConvertTrianglesToAlpha(I->preshader); | auto convertedCGO = CGOConvertTrianglesToAlpha(simplifiedCGO); | |||
I->std = tmpCGO; | CGOFree(simplifiedCGO); | |||
I->std->render_alpha = 1; // CGORenderGL should call CGOSetZVector/CGORe | I->std = convertedCGO; | |||
nderGLAlpha only | if(I->std){ | |||
I->std->render_alpha = 1; // CGORenderGL should call CGOSetZVector/CGO | ||||
RenderGLAlpha only | ||||
} | ||||
} else { | } else { | |||
I->std = CGOSimplify(I->preshader, 0); | I->std = simplifiedCGO; | |||
CHECKOK(ok, I->std); | CHECKOK(ok, I->std); | |||
} | } | |||
I->std = CGOAddTwoSidedBackfaceSpecialOps(G, I->std); | if(I->std) { | |||
I->std = CGOAddTwoSidedBackfaceSpecialOps(G, I->std); | ||||
} | ||||
} | } | |||
} | } | |||
if(I->preshader && (I->ray!=I->preshader)){ | if(I->preshader && (I->ray!=I->preshader)){ | |||
CGOFree(I->preshader); | CGOFree(I->preshader); | |||
} | } | |||
I->preshader = NULL; | I->preshader = NULL; | |||
I->renderWithShaders = use_shaders; | I->renderWithShaders = use_shaders; | |||
return ok; | return ok; | |||
} | } | |||
static void RepCartoonRender(RepCartoon * I, RenderInfo * info) | static void RepCartoonRender(RepCartoon * I, RenderInfo * info) | |||
{ | { | |||
CRay *ray = info->ray; | CRay *ray = info->ray; | |||
Picking **pick = info->pick; | auto pick = info->pick; | |||
PyMOLGlobals *G = I->R.G; | PyMOLGlobals *G = I->R.G; | |||
int ok = true; | int ok = true; | |||
if (!ray && I->preshader) { | if (!ray && I->preshader) { | |||
ok &= RepCartoonCGOGenerate(I, info); | ok &= RepCartoonCGOGenerate(I, info); | |||
} | } | |||
if(ray) { | if(ray) { | |||
#ifndef _PYMOL_NO_RAY | #ifndef _PYMOL_NO_RAY | |||
int try_std = false; | int try_std = false; | |||
skipping to change at line 1025 | skipping to change at line 1039 | |||
color1 = color2 = ColorGet(G, ladder_color); | color1 = color2 = ColorGet(G, ladder_color); | |||
} else { | } else { | |||
color1 = ColorGet(G, g1_ai->color); | color1 = ColorGet(G, g1_ai->color); | |||
color2 = ColorGet(G, g2_ai->color); | color2 = ColorGet(G, g2_ai->color); | |||
} | } | |||
CGOPickColor(cgo, g1, g1_ai->masked ? cPickableNoPick : cPic kableAtom); | CGOPickColor(cgo, g1, g1_ai->masked ? cPickableNoPick : cPic kableAtom); | |||
Pickable pickcolor2 = { g2, g2_ai->masked ? cPickableNoPick : cPickableAtom }; | Pickable pickcolor2 = { g2, g2_ai->masked ? cPickableNoPick : cPickableAtom }; | |||
float axis[3]; | float axis[3]; | |||
subtract3f(g2p, g1p, axis); | subtract3f(g2p, g1p, axis); | |||
CGOColorv(cgo, color1); | CGOColorv(cgo, color1); | |||
cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, g1p, axis, | float ladder_alpha = 1.0f - AtomSettingGetWD(G, ai_i[i], cSe | |||
glyco_radius, 0x1f, color2, &pickcolor2); | tting_cartoon_transparency, 1.0f - alpha); | |||
} | cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, g1p, axis, | |||
glyco_radius, 0x1f, color2, &pickcolor2, ladder_alpha); | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
/* see if any of the neighbors are confirmed nucleic acids... */ | /* see if any of the neighbors are confirmed nucleic acids... */ | |||
if(sugar_at >= 0) { | if(sugar_at >= 0) { | |||
if(!nf) { | if(!nf) { | |||
skipping to change at line 1081 | skipping to change at line 1096 | |||
color1 = color2 = ColorGet(G, ladder_color); | color1 = color2 = ColorGet(G, ladder_color); | |||
} else { | } else { | |||
color1 = ColorGet(G, sug_ai->color); | color1 = ColorGet(G, sug_ai->color); | |||
color2 = ColorGet(G, bas_ai->color); | color2 = ColorGet(G, bas_ai->color); | |||
} | } | |||
CGOPickColor(cgo, sugar_at, sug_ai->masked ? cPickableNoPi ck : cPickableAtom); | CGOPickColor(cgo, sugar_at, sug_ai->masked ? cPickableNoPi ck : cPickableAtom); | |||
Pickable pickcolor2 = { base_at, bas_ai->masked ? cPickabl eNoPick : cPickableAtom }; | Pickable pickcolor2 = { base_at, bas_ai->masked ? cPickabl eNoPick : cPickableAtom }; | |||
float axis[3]; | float axis[3]; | |||
subtract3f(cs->Coord + 3 * bas, cs->Coord + 3 * sug, axis) ; | subtract3f(cs->Coord + 3 * bas, cs->Coord + 3 * sug, axis) ; | |||
CGOColorv(cgo, color1); | CGOColorv(cgo, color1); | |||
cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, cs->Coord | float ladder_alpha = 1.0f - AtomSettingGetWD(G, ai_i[i], c | |||
+ 3 * sug, axis, ladder_radius, 0x1f, color2, &pickcolor2); | Setting_cartoon_transparency, 1.0f - alpha); | |||
} | cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, cs->Coord | |||
+ 3 * sug, axis, ladder_radius, 0x1f, color2, &pickcolor2, ladder_alpha); | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
base_at = save_at; | base_at = save_at; | |||
sugar_at = save_at; | sugar_at = save_at; | |||
} | } | |||
} | } | |||
if((base_at >= 0) && (sugar_at >= 0)) { | if((base_at >= 0) && (sugar_at >= 0)) { | |||
AtomInfoType *sug_ai = atomInfo + sugar_at; | AtomInfoType *sug_ai = atomInfo + sugar_at; | |||
AtomInfoType *bas_ai = atomInfo + base_at; | AtomInfoType *bas_ai = atomInfo + base_at; | |||
skipping to change at line 1160 | skipping to change at line 1176 | |||
} else { | } else { | |||
color1 = ColorGet(G, sug_ai->color); | color1 = ColorGet(G, sug_ai->color); | |||
color2 = ColorGet(G, bas_ai->color); | color2 = ColorGet(G, bas_ai->color); | |||
} | } | |||
CGOPickColor(cgo, sugar_at, sug_ai->masked ? cPickableNoPick : cPickableAtom); | CGOPickColor(cgo, sugar_at, sug_ai->masked ? cPickableNoPick : cPickableAtom); | |||
Pickable pickcolor2 = { base_at, bas_ai->masked ? cPickableNoP ick : cPickableAtom }; | Pickable pickcolor2 = { base_at, bas_ai->masked ? cPickableNoP ick : cPickableAtom }; | |||
float axis[3]; | float axis[3]; | |||
subtract3f(cs->Coord + 3 * bas, v_outer, axis); | subtract3f(cs->Coord + 3 * bas, v_outer, axis); | |||
CGOColorv(cgo, color1); | CGOColorv(cgo, color1); | |||
cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, v_outer, axis | float ladder_alpha = 1.0f - AtomSettingGetWD(G, sug_ai, cSetti | |||
, ladder_radius, 0x1f, color2, &pickcolor2); | ng_cartoon_transparency, 1.0f - alpha); | |||
} | cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, v_outer, axis | |||
, ladder_radius, 0x1f, color2, &pickcolor2, ladder_alpha); | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
if((!ring_mode) || (finder == 2)) { | if((!ring_mode) || (finder == 2)) { | |||
if(ladder_mode) { /* mark sure all rings traversed are mark */ | if(ladder_mode) { /* mark sure all rings traversed are mark */ | |||
int i; | int i; | |||
for(i = 0; i <= n_atom; i++) { | for(i = 0; i <= n_atom; i++) { | |||
skipping to change at line 1222 | skipping to change at line 1239 | |||
float *v_moved = moved + atix[i] * 3; | float *v_moved = moved + atix[i] * 3; | |||
copy3f(avg, v_moved); /* store ring center for later use */ | copy3f(avg, v_moved); /* store ring center for later use */ | |||
} | } | |||
if((nf || (!ladder_mode) || (finder >= 3)) && | if((nf || (!ladder_mode) || (finder >= 3)) && | |||
ring_mode && | ring_mode && | |||
(((finder == 1) && ((have_C4 >= 0) || (have_C4_prime >= 0))) || | (((finder == 1) && ((have_C4 >= 0) || (have_C4_prime >= 0))) || | |||
((finder == 2) && ((have_C4 >= 0))) || | ((finder == 2) && ((have_C4 >= 0))) || | |||
((finder == 3) && ((have_C_number >= 0))) || ((finder == 4)))) { | ((finder == 3) && ((have_C_number >= 0))) || ((finder == 4)))) { | |||
if((alpha != 1.0F) || (ring_alpha != alpha)) | auto atom_alpha = 1.0f - AtomSettingGetWD(G, ai_i[i], cSetting_cartoon_t | |||
CGOAlpha(cgo, ring_alpha); | ransparency, 1.0f - ring_alpha); | |||
if((alpha != 1.0F) || (ring_alpha != alpha) || atom_alpha != 1.0){ | ||||
if(atom_alpha != ring_alpha){ | ||||
CGOAlpha(cgo, atom_alpha); | ||||
} else { | ||||
CGOAlpha(cgo, ring_alpha); | ||||
} | ||||
} | ||||
if(ring_color >= 0) { | if(ring_color >= 0) { | |||
color = ColorGet(G, ring_color); | color = ColorGet(G, ring_color); | |||
} else { | } else { | |||
color = avg_col; | color = avg_col; | |||
} | } | |||
CGOColorv(cgo, color); | CGOColorv(cgo, color); | |||
if((ring_mode == 4) || (ring_mode == 5)) { /* spherical ring */ | if((ring_mode == 4) || (ring_mode == 5)) { /* spherical ring */ | |||
skipping to change at line 1397 | skipping to change at line 1420 | |||
color1 = col[i]; | color1 = col[i]; | |||
color2 = col[ii]; | color2 = col[ii]; | |||
} else { | } else { | |||
color1 = color2 = color; | color1 = color2 = color; | |||
} | } | |||
CGOPickColor(cgo, atix[i], ai_i[i]->masked ? cPickableNoPick : cPickableAtom); | CGOPickColor(cgo, atix[i], ai_i[i]->masked ? cPickableNoPick : cPickableAtom); | |||
Pickable pickcolor2 = { atix[ii], ai_i[ii]->masked ? cPickable NoPick : cPickableAtom }; | Pickable pickcolor2 = { atix[ii], ai_i[ii]->masked ? cPickable NoPick : cPickableAtom }; | |||
float axis[3]; | float axis[3]; | |||
subtract3f(v_i[ii], v_i[i], axis); | subtract3f(v_i[ii], v_i[i], axis); | |||
CGOColorv(cgo, color1); | CGOColorv(cgo, color1); | |||
cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, v_i[i], axis, | float ladder_alpha = 1.0f - AtomSettingGetWD(G, ai_i[i], cSett | |||
ring_width_for_mode, 0x1f, color2, &pickcolor2); | ing_cartoon_transparency, 1.0f - alpha); | |||
} | cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, v_i[i], axis, | |||
ring_width_for_mode, 0x1f, color2, &pickcolor2, ladder_alpha); | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
/* | /* | |||
skipping to change at line 1626 | skipping to change at line 1650 | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
if (ok) | if (ok) | |||
ok &= CGOEnable(cgo, GL_LIGHTING); | ok &= CGOEnable(cgo, GL_LIGHTING); | |||
#endif | #endif | |||
return ok; | return ok; | |||
} | } | |||
static | static | |||
int GenerateRepCartoonProcessCylindricalHelices(PyMOLGlobals * G, ObjectMolecule * obj, CoordSet *cs, CGO *cgo, CExtrude *ex, int nAt, int *seg, float *pv, floa t *tv, float *pvo, | int GenerateRepCartoonProcessCylindricalHelices(PyMOLGlobals * G, ObjectMolecule * obj, CoordSet *cs, CGO *cgo, CExtrude *ex, int nAt, int *seg, float *pv, floa t *tv, float *pvo, | |||
const CCInOut *cc, | const CCInOut *cc, | |||
int *at, float *dl, int cartoon_color, int discrete_colors, float loop_radiu s){ | int *at, float *dl, int cartoon_color, int discrete_colors, float loop_radiu s, const float objAlpha){ | |||
int ok = true; | int ok = true; | |||
int n_p, n_pm1, n_pm2; | int n_p, n_pm1, n_pm2; | |||
const float *v0; | const float *v0; | |||
float *v, *v1, *v2, *vo, *d; | float *v, *v1, *v2, *vo, *d; | |||
float *valpha; | ||||
float *vc = NULL; | float *vc = NULL; | |||
int atom_index1, atom_index2, *s, | int atom_index1, atom_index2, *s, | |||
*atp, a, cur_car; | *atp, a, cur_car; | |||
unsigned *vi; | unsigned *vi; | |||
int last_color, uniform_color; | int last_color, uniform_color; | |||
bool hasAtomLevelTrans = false; | ||||
int contFlag, extrudeFlag; | int contFlag, extrudeFlag; | |||
int b, c1, c2; | int b, c1, c2; | |||
float *h_start = NULL, *h_end = NULL; | float *h_start = NULL, *h_end = NULL; | |||
float t0[3], t1[3], t2[3], t3[3]; | float t0[3], t1[3], t2[3], t3[3]; | |||
float t4[3]; | float t4[3]; | |||
float helix_radius; | float helix_radius; | |||
CGOPickColor(cgo, 0, cPickableNoPick); | CGOPickColor(cgo, 0, cPickableNoPick); | |||
helix_radius = | helix_radius = | |||
SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_helix_radius ); | SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_helix_radius ); | |||
/* this is confusing because we're borrowing Extrude's arrays | /* this is confusing because we're borrowing Extrude's arrays | |||
* for convenient storage, but not actually calling Extrude */ | * for convenient storage, but not actually calling Extrude */ | |||
n_p = 0; | n_p = 0; | |||
v = ex->p; | v = ex->p; | |||
vc = ex->c; | vc = ex->c; | |||
valpha = ex->alpha; | ||||
vi = ex->i; | vi = ex->i; | |||
last_color = -1; | last_color = -1; | |||
uniform_color = true; | uniform_color = true; | |||
v1 = pv; /* points */ | v1 = pv; /* points */ | |||
v2 = tv; /* tangents */ | v2 = tv; /* tangents */ | |||
vo = pvo; | vo = pvo; | |||
d = dl; | d = dl; | |||
s = seg; | s = seg; | |||
skipping to change at line 1676 | skipping to change at line 1703 | |||
while(contFlag) { | while(contFlag) { | |||
if((*cc) != cur_car) { /* new cartoon type */ | if((*cc) != cur_car) { /* new cartoon type */ | |||
if(n_p) { /* any cartoon points? */ | if(n_p) { /* any cartoon points? */ | |||
extrudeFlag = true; | extrudeFlag = true; | |||
} else { | } else { | |||
cur_car = *(cc); /* now: go ahead and switch cartoons */ | cur_car = *(cc); /* now: go ahead and switch cartoons */ | |||
n_p = 0; | n_p = 0; | |||
v = ex->p; | v = ex->p; | |||
vc = ex->c; | vc = ex->c; | |||
valpha = ex->alpha; | ||||
vi = ex->i; | vi = ex->i; | |||
last_color = -1; | last_color = -1; | |||
uniform_color = true; | uniform_color = true; | |||
} | } | |||
} | } | |||
if(a && !extrudeFlag) { | if(a && !extrudeFlag) { | |||
if((*s) != *(s - 1)) { /* new segment */ | if((*s) != *(s - 1)) { /* new segment */ | |||
if(n_p) { /* any cartoon points? */ | if(n_p) { /* any cartoon points? */ | |||
extrudeFlag = true; | extrudeFlag = true; | |||
} else { | } else { | |||
n_p = 0; | n_p = 0; | |||
v = ex->p; | v = ex->p; | |||
vc = ex->c; | vc = ex->c; | |||
valpha = ex->alpha; | ||||
vi = ex->i; | vi = ex->i; | |||
last_color = -1; | last_color = -1; | |||
uniform_color = true; | uniform_color = true; | |||
} | } | |||
} | } | |||
} | } | |||
if(!extrudeFlag) { | if(!extrudeFlag) { | |||
if((a < (nAt - 1)) && (*s == *(s + 1))) { /* working in the same seg ment... */ | if((a < (nAt - 1)) && (*s == *(s + 1))) { /* working in the same seg ment... */ | |||
AtomInfoType *ai1, *ai2; | AtomInfoType *ai1, *ai2; | |||
atom_index1 = cs->IdxToAtm[*atp]; | atom_index1 = cs->IdxToAtm[*atp]; | |||
atom_index2 = cs->IdxToAtm[*(atp + 1)]; | atom_index2 = cs->IdxToAtm[*(atp + 1)]; | |||
ai1 = obj->AtomInfo + atom_index1; | ai1 = obj->AtomInfo + atom_index1; | |||
ai2 = obj->AtomInfo + atom_index2; | ai2 = obj->AtomInfo + atom_index2; | |||
c1 = AtomSettingGetWD(G, ai1, cSetting_cartoon_color, cartoon_color); | c1 = AtomSettingGetWD(G, ai1, cSetting_cartoon_color, cartoon_color); | |||
c2 = AtomSettingGetWD(G, ai2, cSetting_cartoon_color, cartoon_color); | c2 = AtomSettingGetWD(G, ai2, cSetting_cartoon_color, cartoon_color); | |||
float alpha1 = 1.0f - AtomSettingGetWD(G, ai1, cSetting_cartoon_transpar | ||||
ency, 1.0f - objAlpha); | ||||
float alpha2 = 1.0f - AtomSettingGetWD(G, ai2, cSetting_cartoon_transpar | ||||
ency, 1.0f - objAlpha); | ||||
if (!hasAtomLevelTrans && (alpha1 != objAlpha || alpha2 != objAlpha)) { | ||||
hasAtomLevelTrans = true; | ||||
} | ||||
if (c1 < 0) c1 = ai1->color; | if (c1 < 0) c1 = ai1->color; | |||
if (c2 < 0) c2 = ai2->color; | if (c2 < 0) c2 = ai2->color; | |||
if((*(cc) == *(cc + 1)) && (c1 != c2)) | if((*(cc) == *(cc + 1)) && (c1 != c2)) | |||
uniform_color = false; | uniform_color = false; | |||
if(last_color >= 0) { | if(last_color >= 0) { | |||
if(c1 != last_color) | if(c1 != last_color) | |||
uniform_color = false; | uniform_color = false; | |||
} | } | |||
last_color = c1; | last_color = c1; | |||
v0 = ColorGet(G, c1); | v0 = ColorGet(G, c1); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(valpha++) = alpha1; | ||||
*(vi++) = ai1->masked ? -1 : atom_index1; | *(vi++) = ai1->masked ? -1 : atom_index1; | |||
v0 = ColorGet(G, c2); /* kludge */ | v0 = ColorGet(G, c2); /* kludge */ | |||
*(vc) = *(v0++); | *(vc) = *(v0++); | |||
*(vc + 1) = *(v0++); | *(vc + 1) = *(v0++); | |||
*(vc + 2) = *(v0++); | *(vc + 2) = *(v0++); | |||
*(valpha) = alpha2; | ||||
*(vi) = ai2->masked ? -1 : atom_index2; | *(vi) = ai2->masked ? -1 : atom_index2; | |||
} else { | } else { | |||
vc += 3; /* part of kludge */ | vc += 3; /* part of kludge */ | |||
valpha++; | ||||
vi++; | vi++; | |||
} | } | |||
if(cur_car == cCartoon_skip_helix) { | if(cur_car == cCartoon_skip_helix) { | |||
if(!n_p) { | if(!n_p) { | |||
h_start = v1; | h_start = v1; | |||
h_end = v1; | h_end = v1; | |||
} else { | } else { | |||
h_end = v1; | h_end = v1; | |||
} | } | |||
copy3f(v1, v); /* just store coordinates until we have a complete cylinder */ | copy3f(v1, v); /* just store coordinates until we have a complete cylinder */ | |||
skipping to change at line 1764 | skipping to change at line 1802 | |||
if(n_p) | if(n_p) | |||
extrudeFlag = true; | extrudeFlag = true; | |||
} | } | |||
if(extrudeFlag) { /* generate cylinder */ | if(extrudeFlag) { /* generate cylinder */ | |||
if(n_p > 1) { | if(n_p > 1) { | |||
atom_index1 = cs->IdxToAtm[*(atp - 1)]; | atom_index1 = cs->IdxToAtm[*(atp - 1)]; | |||
c1 = AtomSettingGetWD(G, obj->AtomInfo + atom_index1, | c1 = AtomSettingGetWD(G, obj->AtomInfo + atom_index1, | |||
cSetting_cartoon_color, cartoon_color); | cSetting_cartoon_color, cartoon_color); | |||
auto ai1 = obj->AtomInfo + atom_index1; | ||||
auto ai2 = obj->AtomInfo + atom_index2; | ||||
float alpha1 = 1.0f - AtomSettingGetWD(G, ai1, cSetting_cartoon_transpar | ||||
ency, 1.0f - objAlpha); | ||||
float alpha2 = 1.0f - AtomSettingGetWD(G, ai2, cSetting_cartoon_transpar | ||||
ency, 1.0f - objAlpha); | ||||
if(!hasAtomLevelTrans && (alpha1 != objAlpha || alpha2 != objAlpha)){ | ||||
hasAtomLevelTrans = true; | ||||
} | ||||
if (c1 < 0) c1 = (obj->AtomInfo + atom_index1)->color; | if (c1 < 0) c1 = (obj->AtomInfo + atom_index1)->color; | |||
if(n_p < 5) { | if(n_p < 5) { | |||
copy3f(ex->p, t3); | copy3f(ex->p, t3); | |||
copy3f(v - 3, t4); | copy3f(v - 3, t4); | |||
} else { | } else { | |||
add3f(ex->p, ex->p + 9, t0); | add3f(ex->p, ex->p + 9, t0); | |||
add3f(ex->p + 3, ex->p + 6, t1); | add3f(ex->p + 3, ex->p + 6, t1); | |||
scale3f(t0, 0.2130F, t0); | scale3f(t0, 0.2130F, t0); | |||
scale3f(t1, 0.2870F, t1); | scale3f(t1, 0.2870F, t1); | |||
skipping to change at line 1817 | skipping to change at line 1863 | |||
} | } | |||
} | } | |||
} | } | |||
/* push helix out a tad to consume loop */ | /* push helix out a tad to consume loop */ | |||
subtract3f(t4, t3, t0); | subtract3f(t4, t3, t0); | |||
normalize3f(t0); | normalize3f(t0); | |||
scale3f(t0, loop_radius * 2, t0); | scale3f(t0, loop_radius * 2, t0); | |||
add3f(t0, t4, t4); | add3f(t0, t4, t4); | |||
invert3f(t0); | invert3f(t0); | |||
add3f(t0, t3, t3); | add3f(t0, t3, t3); | |||
if(uniform_color && !hasAtomLevelTrans) { | ||||
if(uniform_color) { | cgo->add<cgo::draw::cylinder>(t3, t4, helix_radius, ex->c, ex->c); | |||
CGOCylinderv(cgo, t3, t4, helix_radius, ex->c, ex->c); | ||||
} else { | } else { | |||
subtract3f(t4, t3, t0); | subtract3f(t4, t3, t0); | |||
n_pm1 = n_p - 1; | n_pm1 = n_p - 1; | |||
n_pm2 = n_p - 2; | n_pm2 = n_p - 2; | |||
for(b = 0; ok && b < n_pm1; b++) { | for(b = 0; ok && b < n_pm1; b++) { | |||
if(!b) { | scale3f(t0, ((float) b) / n_pm1, t1); | |||
scale3f(t0, ((float) b - 0.005F) / n_pm1, t1); /* add small overl | scale3f(t0, ((float) b + 1) / n_pm1, t2); | |||
ap */ | ||||
} else { | ||||
scale3f(t0, ((float) b) / n_pm1, t1); | ||||
} | ||||
if(b < n_pm2) { | ||||
scale3f(t0, ((float) b + 1.005F) / n_pm1, t2); | ||||
} else { | ||||
scale3f(t0, ((float) b + 1) / n_pm1, t2); | ||||
} | ||||
add3f(t3, t1, t1); | add3f(t3, t1, t1); | |||
add3f(t3, t2, t2); | add3f(t3, t2, t2); | |||
CGOCustomCylinderv(cgo, t1, t2, helix_radius, ex->c + (b * 3), | if(hasAtomLevelTrans){ | |||
cgo->add<cgo::draw::custom_cylinder_alpha>(t1, t2, helix_radius, e | ||||
x->c + (b * 3), | ||||
ex->c + (b + 1) * 3, ex->alpha[b], ex->alph | ||||
a[b + 1], (float) (b ? 0 : cCylCapFlat), | ||||
(float) (b == n_pm2 ? cCylCapFlat : 0)); | ||||
} else { | ||||
cgo->add<cgo::draw::custom_cylinder>(t1, t2, helix_radius, ex->c + | ||||
(b * 3), | ||||
ex->c + (b + 1) * 3, (float) (b ? 0 : cCylC apFlat), | ex->c + (b + 1) * 3, (float) (b ? 0 : cCylC apFlat), | |||
(float) (b == n_pm2 ? cCylCapFlat : 0)); | (float) (b == n_pm2 ? cCylCapFlat : 0)); | |||
} | ||||
} | } | |||
} | } | |||
} | } | |||
a--; /* undo above... */ | a--; /* undo above... */ | |||
extrudeFlag = false; | extrudeFlag = false; | |||
n_p = 0; | n_p = 0; | |||
v = ex->p; | v = ex->p; | |||
vc = ex->c; | vc = ex->c; | |||
valpha = ex->alpha; | ||||
vi = ex->i; | vi = ex->i; | |||
uniform_color = true; | uniform_color = true; | |||
last_color = -1; | last_color = -1; | |||
} | } | |||
} | } | |||
return ok; | return ok; | |||
} | } | |||
static | static | |||
int GenerateRepCartoonDrawRings(PyMOLGlobals * G, nuc_acid_data *ndata, ObjectMo lecule * obj, | int GenerateRepCartoonDrawRings(PyMOLGlobals * G, nuc_acid_data *ndata, ObjectMo lecule * obj, | |||
skipping to change at line 2002 | skipping to change at line 2048 | |||
} | } | |||
escape: | escape: | |||
escape_count = ESCAPE_MAX; /* don't get bogged down with structures | escape_count = ESCAPE_MAX; /* don't get bogged down with structures | |||
that have unreasonable connectivity */ | that have unreasonable connectivity */ | |||
} | } | |||
FreeP(marked); | FreeP(marked); | |||
FreeP(moved); | FreeP(moved); | |||
return ok; | return ok; | |||
} | } | |||
#define EXTRUDE_TRUNCATE() { ExtrudeTruncate(ex, 0); n_p = 0; v = ex->p; | ||||
\ | ||||
vc = ex->c; vn = ex->n; vi = ex->i; } | ||||
/* | /* | |||
* skip > dash > loop | * skip > dash > loop | |||
*/ | */ | |||
inline int prioritize(int a, int b) { | inline int prioritize(int a, int b) { | |||
if (a == b) | if (a == b) | |||
return a; | return a; | |||
if (a == cCartoon_skip || b == cCartoon_skip) | if (a == cCartoon_skip || b == cCartoon_skip) | |||
return cCartoon_skip; | return cCartoon_skip; | |||
if (a == cCartoon_dash || b == cCartoon_dash) | if (a == cCartoon_dash || b == cCartoon_dash) | |||
return cCartoon_dash; | return cCartoon_dash; | |||
skipping to change at line 2050 | skipping to change at line 2093 | |||
truncate = true; | truncate = true; | |||
} | } | |||
} | } | |||
return truncate; | return truncate; | |||
} | } | |||
static | static | |||
void ComputeCartoonAtomColors(PyMOLGlobals *G, ObjectMolecule *obj, CoordSet *cs , int *nuc_flag, int atom_index1, int atom_index2, int *c1a, int *c2a, int *atp, | void ComputeCartoonAtomColors(PyMOLGlobals *G, ObjectMolecule *obj, CoordSet *cs , int *nuc_flag, int atom_index1, int atom_index2, int *c1a, int *c2a, int *atp, | |||
const CCInOut *cc, | const CCInOut *cc, | |||
int cur_car, int cartoon_color, int nucleic_color, int discrete_colors, int n_p, int contigFlag){ | int cur_car, int cartoon_color, float& alpha1, float& alpha2, int nucleic_co lor, int discrete_colors, int n_p, int contigFlag){ | |||
int c1, c2; | int c1, c2; | |||
if (nucleic_color >= 0 && (nuc_flag[*atp] || nuc_flag[*(atp + 1)])) { | if (nucleic_color >= 0 && (nuc_flag[*atp] || nuc_flag[*(atp + 1)])) { | |||
c1 = c2 = nucleic_color; | c1 = c2 = nucleic_color; | |||
} else { | } else { | |||
c1 = c2 = cartoon_color; | c1 = c2 = cartoon_color; | |||
} | } | |||
auto ai1 = obj->AtomInfo + atom_index1; | auto ai1 = obj->AtomInfo + atom_index1; | |||
auto ai2 = obj->AtomInfo + atom_index2; | auto ai2 = obj->AtomInfo + atom_index2; | |||
AtomSettingGetIfDefined(G, ai1, cSetting_cartoon_color, &c1); | AtomSettingGetIfDefined(G, ai1, cSetting_cartoon_color, &c1); | |||
AtomSettingGetIfDefined(G, ai2, cSetting_cartoon_color, &c2); | AtomSettingGetIfDefined(G, ai2, cSetting_cartoon_color, &c2); | |||
alpha1 = 1.0f - AtomSettingGetWD(G, ai1, cSetting_cartoon_transparency, 1.0f - | ||||
alpha1); | ||||
alpha2 = 1.0f - AtomSettingGetWD(G, ai2, cSetting_cartoon_transparency, 1.0f - | ||||
alpha2); | ||||
if (c1 < 0) c1 = ai1->color; | if (c1 < 0) c1 = ai1->color; | |||
if (c2 < 0) c2 = ai2->color; | if (c2 < 0) c2 = ai2->color; | |||
if(discrete_colors) { | if(discrete_colors) { | |||
int next_car = *(cc + 1); | int next_car = *(cc + 1); | |||
// end of loop or dash segment | // end of loop or dash segment | |||
if (cur_car != next_car) { | if (cur_car != next_car) { | |||
if (cur_car == cCartoon_dash) { | if (cur_car == cCartoon_dash) { | |||
c2 = c1; | c2 = c1; | |||
skipping to change at line 2095 | skipping to change at line 2140 | |||
c1 = c2; | c1 = c2; | |||
} | } | |||
} | } | |||
*c1a = c1; | *c1a = c1; | |||
*c2a = c2; | *c2a = c2; | |||
} | } | |||
static | static | |||
void CartoonGenerateSample(PyMOLGlobals *G, int sampling, int *n_p, float dev, f loat *vo, | void CartoonGenerateSample(PyMOLGlobals *G, int sampling, int *n_p, float dev, f loat *vo, | |||
float *v1, | float *v1, | |||
float *v2, int c1, int c2, int atom_index1, int atom_ | float *v2, int c1, int c2, float alpha1, float alpha2 | |||
index2, | , | |||
float power_a, float power_b, float **vc_p, unsigned | int atom_index1, int atom_index2, | |||
int **vi_p, | float power_a, float power_b, float **vc_p, float **v | |||
float **v_p, float **vn_p){ | alpha_p, | |||
unsigned int **vi_p, float **v_p, float **vn_p){ | ||||
int b, i0; | int b, i0; | |||
float f0, f1, f2, f3, f4; | float f0, f1, f2, f3, f4; | |||
float a0; | ||||
const float *v0; | const float *v0; | |||
unsigned int *vi = *vi_p; | unsigned int *vi = *vi_p; | |||
float *valpha = *valpha_p; | ||||
float *vc = *vc_p, *v = *v_p, *vn = *vn_p; | float *vc = *vc_p, *v = *v_p, *vn = *vn_p; | |||
for(b = 0; b < sampling; b++) { /* needs optimization */ | for(b = 0; b < sampling; b++) { /* needs optimization */ | |||
if(*n_p == 0) { | if(*n_p == 0) { | |||
/* provide starting point on first point in segment only... */ | /* provide starting point on first point in segment only... */ | |||
f0 = ((float) b) / sampling; /* fraction of completion */ | f0 = ((float) b) / sampling; /* fraction of completion */ | |||
if(f0 <= 0.5) { | if(f0 <= 0.5) { | |||
v0 = ColorGet(G, c1); | v0 = ColorGet(G, c1); | |||
i0 = atom_index1; | i0 = atom_index1; | |||
a0 = alpha1; | ||||
} else { | } else { | |||
v0 = ColorGet(G, c2); | v0 = ColorGet(G, c2); | |||
i0 = atom_index2; | i0 = atom_index2; | |||
a0 = alpha2; | ||||
} | } | |||
f0 = smooth(f0, power_a); /* bias sampling towards the center of the curve */ | f0 = smooth(f0, power_a); /* bias sampling towards the center of the curve */ | |||
/* store colors */ | /* store colors and alpha*/ | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(valpha++) = a0; | ||||
*(vi++) = i0; | *(vi++) = i0; | |||
/* start of line/cylinder */ | /* start of line/cylinder */ | |||
f1 = 1.0F - f0; | f1 = 1.0F - f0; | |||
f2 = smooth(f0, power_b); | f2 = smooth(f0, power_b); | |||
f3 = smooth(f1, power_b); | f3 = smooth(f1, power_b); | |||
f4 = dev * f2 * f3; /* displacement magnitude */ | f4 = dev * f2 * f3; /* displacement magnitude */ | |||
*(v++) = f1 * v1[0] + f0 * v1[3] + f4 * (f3 * v2[0] - f2 * v2[3]); | *(v++) = f1 * v1[0] + f0 * v1[3] + f4 * (f3 * v2[0] - f2 * v2[3]); | |||
*(v++) = f1 * v1[1] + f0 * v1[4] + f4 * (f3 * v2[1] - f2 * v2[4]); | *(v++) = f1 * v1[1] + f0 * v1[4] + f4 * (f3 * v2[1] - f2 * v2[4]); | |||
*(v++) = f1 * v1[2] + f0 * v1[5] + f4 * (f3 * v2[2] - f2 * v2[5]); | *(v++) = f1 * v1[2] + f0 * v1[5] + f4 * (f3 * v2[2] - f2 * v2[5]); | |||
vn += 9; | vn += 9; | |||
copy3f(vo, vn - 6); /* starter... */ | copy3f(vo, vn - 6); /* starter... */ | |||
(*n_p)++; | (*n_p)++; | |||
} | } | |||
f0 = ((float) b + 1) / sampling; | f0 = ((float) b + 1) / sampling; | |||
if(f0 <= 0.5) { | if(f0 <= 0.5) { | |||
v0 = ColorGet(G, c1); | v0 = ColorGet(G, c1); | |||
i0 = atom_index1; | i0 = atom_index1; | |||
a0 = alpha1; | ||||
} else { | } else { | |||
v0 = ColorGet(G, c2); | v0 = ColorGet(G, c2); | |||
i0 = atom_index2; | i0 = atom_index2; | |||
a0 = alpha2; | ||||
} | } | |||
f0 = smooth(f0, power_a); /* bias sampling towards the center of the curve */ | f0 = smooth(f0, power_a); /* bias sampling towards the center of the curve */ | |||
/* store colors */ | /* store colors and alpha*/ | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(vc++) = *(v0++); | *(vc++) = *(v0++); | |||
*(valpha++) = a0; | ||||
*(vi++) = i0; | *(vi++) = i0; | |||
/* end of line/cylinder */ | /* end of line/cylinder */ | |||
f1 = 1.0F - f0; | f1 = 1.0F - f0; | |||
f2 = smooth(f0, power_b); | f2 = smooth(f0, power_b); | |||
f3 = smooth(f1, power_b); | f3 = smooth(f1, power_b); | |||
f4 = dev * f2 * f3; /* displacement magnitude */ | f4 = dev * f2 * f3; /* displacement magnitude */ | |||
*(v++) = f1 * v1[0] + f0 * v1[3] + f4 * (f3 * v2[0] - f2 * v2[3]); | *(v++) = f1 * v1[0] + f0 * v1[3] + f4 * (f3 * v2[0] - f2 * v2[3]); | |||
*(v++) = f1 * v1[1] + f0 * v1[4] + f4 * (f3 * v2[1] - f2 * v2[4]); | *(v++) = f1 * v1[1] + f0 * v1[4] + f4 * (f3 * v2[1] - f2 * v2[4]); | |||
skipping to change at line 2171 | skipping to change at line 2225 | |||
*(vn++) = f1 * (vo[0] * f2) + f0 * (vo[3] * f3); | *(vn++) = f1 * (vo[0] * f2) + f0 * (vo[3] * f3); | |||
*(vn++) = f1 * (vo[1] * f2) + f0 * (vo[4] * f3); | *(vn++) = f1 * (vo[1] * f2) + f0 * (vo[4] * f3); | |||
*(vn++) = f1 * (vo[2] * f2) + f0 * (vo[5] * f3); | *(vn++) = f1 * (vo[2] * f2) + f0 * (vo[5] * f3); | |||
vn += 3; | vn += 3; | |||
if(b == sampling - 1) | if(b == sampling - 1) | |||
copy3f(vo + 3, vn - 6); /* starter... */ | copy3f(vo + 3, vn - 6); /* starter... */ | |||
(*n_p)++; | (*n_p)++; | |||
} | } | |||
(*vc_p) = vc; | (*vc_p) = vc; | |||
(*valpha_p) = valpha; | ||||
(*vi_p) = vi; | (*vi_p) = vi; | |||
(*v_p) = v; | (*v_p) = v; | |||
(*vn_p) = vn; | (*vn_p) = vn; | |||
} | } | |||
static | static | |||
void CartoonGenerateRefine(int refine, int sampling, float *v, float *vn, float *vo, float *sampling_tmp){ | void CartoonGenerateRefine(int refine, int sampling, float *v, float *vn, float *vo, float *sampling_tmp){ | |||
int b, c; | int b, c; | |||
float t0[3], t1[3]; | float t0[3], t1[3]; | |||
float *p0, *p1, *p2, *p3; | float *p0, *p1, *p2, *p3; | |||
skipping to change at line 2327 | skipping to change at line 2382 | |||
ExtrudeCircle(ex,loop_quality,loop_radius); | ExtrudeCircle(ex,loop_quality,loop_radius); | |||
ExtrudeBuildNormals1f(ex); | ExtrudeBuildNormals1f(ex); | |||
ExtrudeCGOSurfaceTube(ex,cgo,loop_cap,NULL); | ExtrudeCGOSurfaceTube(ex,cgo,loop_cap,NULL); | |||
*/ | */ | |||
return ok; | return ok; | |||
} | } | |||
static | static | |||
int CartoonExtrudeDumbbell(PyMOLGlobals *G, CExtrude *ex, CGO *cgo, int sampling , float dumbbell_width, float dumbbell_length, int highlight_color, int loop_qua lity, float dumbbell_radius, short use_cylinders_for_strands){ | int CartoonExtrudeDumbbell(PyMOLGlobals *G, CExtrude *ex, CGO *cgo, int sampling , float dumbbell_width, float dumbbell_length, int highlight_color, int loop_qua lity, float dumbbell_radius, short use_cylinders_for_strands){ | |||
int ok; | int ok; | |||
CExtrude *ex1; | CExtrude *ex1 = nullptr; | |||
if(highlight_color < 0) { | if(highlight_color < 0) { | |||
ok = ExtrudeDumbbell1(ex, dumbbell_width, dumbbell_length, 0); | ok = ExtrudeDumbbell1(ex, dumbbell_width, dumbbell_length, 0); | |||
if (ok) | if (ok) | |||
ExtrudeBuildNormals2f(ex); | ExtrudeBuildNormals2f(ex); | |||
if (ok) | if (ok) | |||
ok &= ExtrudeCGOSurfacePolygonTaper(ex, cgo, sampling, NULL); | ok &= ExtrudeCGOSurfacePolygonTaper(ex, cgo, sampling, NULL); | |||
} else { | } else { | |||
ok = ExtrudeDumbbell1(ex, dumbbell_width, dumbbell_length, 1); | ok = ExtrudeDumbbell1(ex, dumbbell_width, dumbbell_length, 1); | |||
if (ok) | if (ok) | |||
ExtrudeBuildNormals2f(ex); | ExtrudeBuildNormals2f(ex); | |||
skipping to change at line 2423 | skipping to change at line 2478 | |||
PyMOLGlobals *G = cs->State.G; | PyMOLGlobals *G = cs->State.G; | |||
int ok = true; | int ok = true; | |||
CGO *cgo; | CGO *cgo; | |||
int contigFlag, contFlag, extrudeFlag, n_p; | int contigFlag, contFlag, extrudeFlag, n_p; | |||
CExtrude *ex = NULL; | CExtrude *ex = NULL; | |||
float dev; | float dev; | |||
unsigned int *vi; | unsigned int *vi; | |||
int atom_index1, atom_index2; | int atom_index1, atom_index2; | |||
float *v, *v1, *v2, *vo; | float *v, *v1, *v2, *vo; | |||
float *d, *vc = NULL, *vn; | float *d, *vc = NULL, *vn; | |||
float *valpha = nullptr; | ||||
int *atp; | int *atp; | |||
int c1, c2; | int c1, c2; | |||
int a; | int a; | |||
int sampling; | int sampling; | |||
float *sampling_tmp; | float *sampling_tmp; | |||
int *segptr; | int *segptr; | |||
const CCInOut *cc; | const CCInOut *cc; | |||
int cur_car; | int cur_car; | |||
float loop_radius; | float loop_radius; | |||
int nucleic_color = 0; | int nucleic_color = 0; | |||
skipping to change at line 2445 | skipping to change at line 2501 | |||
float power_b = 5; | float power_b = 5; | |||
int refine; | int refine; | |||
float tube_radius; | float tube_radius; | |||
float putty_radius; | float putty_radius; | |||
int cartoon_debug, cylindrical_helices, cartoon_color, highlight_color, | int cartoon_debug, cylindrical_helices, cartoon_color, highlight_color, | |||
discrete_colors, loop_quality, oval_quality, tube_quality, putty_quality, lo op_cap, tube_cap; | discrete_colors, loop_quality, oval_quality, tube_quality, putty_quality, lo op_cap, tube_cap; | |||
float length, width; | float length, width; | |||
float oval_width, oval_length; | float oval_width, oval_length; | |||
float dumbbell_radius, dumbbell_width, dumbbell_length; | float dumbbell_radius, dumbbell_width, dumbbell_length; | |||
float ring_width; | float ring_width; | |||
auto EXTRUDE_TRUNCATE = [&ex, &n_p, &v, &vc, &valpha, &vn, &vi]() { | ||||
ExtrudeTruncate(ex, 0); | ||||
n_p = 0; | ||||
v = ex->p; | ||||
vc = ex->c; | ||||
valpha = ex->alpha; | ||||
vn = ex->n; | ||||
vi = ex->i; | ||||
}; | ||||
cartoon_color = | cartoon_color = | |||
SettingGet_color(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_color); | SettingGet_color(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_color); | |||
ring_width = | ring_width = | |||
SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_ring_width); | SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_ring_width); | |||
if(ring_width < 0.0F) { | if(ring_width < 0.0F) { | |||
ring_width = | ring_width = | |||
fabs(SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_stick_radius) ) * 0.5F; | fabs(SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_stick_radius) ) * 0.5F; | |||
} | } | |||
length = SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_rect_ length); | length = SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_rect_ length); | |||
width = SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_rect_w idth); | width = SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_cartoon_rect_w idth); | |||
skipping to change at line 2538 | skipping to change at line 2605 | |||
/* okay, we now have enough info to generate smooth interpolations */ | /* okay, we now have enough info to generate smooth interpolations */ | |||
if(nAt > 1) { | if(nAt > 1) { | |||
ex = ExtrudeNew(G); | ex = ExtrudeNew(G); | |||
CHECKOK(ok, ex); | CHECKOK(ok, ex); | |||
if (ok) | if (ok) | |||
ok &= ExtrudeAllocPointsNormalsColors(ex, cs->NIndex * (3 * sampling + 3)) ; | ok &= ExtrudeAllocPointsNormalsColors(ex, cs->NIndex * (3 * sampling + 3)) ; | |||
} | } | |||
/* process cylindrical helices first */ | /* process cylindrical helices first */ | |||
if(ok && (nAt > 1) && cylindrical_helices) { | if(ok && (nAt > 1) && cylindrical_helices) { | |||
ok = GenerateRepCartoonProcessCylindricalHelices(G, obj, cs, cgo, ex, nAt, s eg, pv, tv, | ok = GenerateRepCartoonProcessCylindricalHelices(G, obj, cs, cgo, ex, nAt, s eg, pv, tv, | |||
pvo, car, at, dl, cartoon_c olor, discrete_colors, loop_radius); | pvo, car, at, dl, cartoon_c olor, discrete_colors, loop_radius, alpha); | |||
} | } | |||
if(ok && nAt > 1) { | if(ok && nAt > 1) { | |||
EXTRUDE_TRUNCATE(); | EXTRUDE_TRUNCATE(); | |||
v1 = pv; /* points */ | v1 = pv; /* points */ | |||
v2 = tv; /* tangents */ | v2 = tv; /* tangents */ | |||
vo = pvo; | vo = pvo; | |||
d = dl; | d = dl; | |||
segptr = seg; | segptr = seg; | |||
cc = car; | cc = car; | |||
atp = at; /* cs index pointer */ | atp = at; /* cs index pointer */ | |||
skipping to change at line 2567 | skipping to change at line 2634 | |||
EXTRUDE_TRUNCATE(); | EXTRUDE_TRUNCATE(); | |||
} | } | |||
if(ok && !extrudeFlag) { | if(ok && !extrudeFlag) { | |||
if((a < (nAt - 1)) && (*segptr == *(segptr + 1))) { /* working in the same segment... */ | if((a < (nAt - 1)) && (*segptr == *(segptr + 1))) { /* working in the same segment... */ | |||
AtomInfoType *ai1, *ai2; | AtomInfoType *ai1, *ai2; | |||
atom_index1 = cs->IdxToAtm[*atp]; | atom_index1 = cs->IdxToAtm[*atp]; | |||
atom_index2 = cs->IdxToAtm[*(atp + 1)]; | atom_index2 = cs->IdxToAtm[*(atp + 1)]; | |||
ai1 = obj->AtomInfo + atom_index1; | ai1 = obj->AtomInfo + atom_index1; | |||
ai2 = obj->AtomInfo + atom_index2; | ai2 = obj->AtomInfo + atom_index2; | |||
ComputeCartoonAtomColors(G, obj, cs, nuc_flag, atom_index1, atom_index 2, &c1, &c2, atp, cc, cur_car, cartoon_color, nucleic_color, discrete_colors, n_ p, contigFlag); | ||||
float alpha1 = alpha; | ||||
float alpha2 = alpha; | ||||
ComputeCartoonAtomColors(G, obj, cs, nuc_flag, atom_index1, atom_index | ||||
2, &c1, &c2, atp, cc, cur_car, cartoon_color, alpha1, alpha2, nucleic_color, dis | ||||
crete_colors, n_p, contigFlag); | ||||
dev = throw_ * (*d); | dev = throw_ * (*d); | |||
CartoonGenerateSample(G, sampling, &n_p, dev, vo, v1, v2, c1, c2, | CartoonGenerateSample(G, sampling, &n_p, dev, vo, v1, v2, c1, c2, alph | |||
ai1->masked ? -1 : atom_index1, ai2->masked ? -1 | a1, alpha2, | |||
: atom_index2, power_a, power_b, &vc, &vi, &v, &vn); | ai1->masked ? -1 : atom_index1, ai2->masked ? -1 | |||
: atom_index2, power_a, power_b, &vc, &valpha, &vi, &v, &vn); | ||||
/* now do a smoothing pass along orientation | /* now do a smoothing pass along orientation | |||
vector to smooth helices, etc... */ | vector to smooth helices, etc... */ | |||
CartoonGenerateRefine(refine, sampling, v, vn, vo, sampling_tmp); | CartoonGenerateRefine(refine, sampling, v, vn, vo, sampling_tmp); | |||
} | } | |||
v1 += 3; | v1 += 3; | |||
v2 += 3; | v2 += 3; | |||
vo += 3; | vo += 3; | |||
d++; | d++; | |||
atp += 1; | atp += 1; | |||
End of changes. 50 change blocks. | ||||
61 lines changed or deleted | 145 lines changed or added |