RepNonbondedSphere.cpp (pymol-v2.1.0.tar.bz2) | : | RepNonbondedSphere.cpp (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
#include"Color.h" | #include"Color.h" | |||
#include"Sphere.h" | #include"Sphere.h" | |||
#include"Setting.h" | #include"Setting.h" | |||
#include"main.h" | #include"main.h" | |||
#include"ShaderMgr.h" | #include"ShaderMgr.h" | |||
#include"Scene.h" | #include"Scene.h" | |||
#include"CGO.h" | #include"CGO.h" | |||
typedef struct RepNonbondedSphere { | typedef struct RepNonbondedSphere { | |||
Rep R; | Rep R; | |||
float *V; | CGO *shaderCGO, *primitiveCGO; | |||
float *VC; | ||||
SphereRec *SP; | ||||
int N, NC; | ||||
float *VP; | ||||
Pickable *P; | ||||
int NP; | ||||
int VariableAlphaFlag; | ||||
CGO *shaderCGO; | ||||
} RepNonbondedSphere; | } RepNonbondedSphere; | |||
#include"ObjectMolecule.h" | #include"ObjectMolecule.h" | |||
void RepNonbondedSphereFree(RepNonbondedSphere * I); | void RepNonbondedSphereFree(RepNonbondedSphere * I); | |||
void RepNonbondedSphereInit(void) | void RepNonbondedSphereInit(void) | |||
{ | { | |||
} | } | |||
void RepNonbondedSphereFree(RepNonbondedSphere * I) | void RepNonbondedSphereFree(RepNonbondedSphere * I) | |||
{ | { | |||
if (I->shaderCGO){ | if (I->shaderCGO){ | |||
CGOFree(I->shaderCGO); | CGOFree(I->shaderCGO); | |||
I->shaderCGO = 0; | I->shaderCGO = 0; | |||
} | } | |||
FreeP(I->VP); | if (I->primitiveCGO){ | |||
CGOFree(I->primitiveCGO); | ||||
I->primitiveCGO = 0; | ||||
} | ||||
RepPurge(&I->R); | RepPurge(&I->R); | |||
FreeP(I->VC); | ||||
FreeP(I->V); | ||||
OOFreeP(I); | OOFreeP(I); | |||
} | } | |||
static void RepNonbondedSphereRender(RepNonbondedSphere * I, RenderInfo * info) | static void RepNonbondedSphereRender(RepNonbondedSphere * 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; | ||||
int c = I->N; | ||||
int cc = 0; | ||||
int a; | ||||
SphereRec *sp; | ||||
int i, j; | ||||
Pickable *p; | ||||
int ok = true; | ||||
float alpha; | ||||
alpha = | ||||
SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_nonbonded_tran | ||||
sparency); | ||||
alpha = 1.0F - alpha; | ||||
if(fabs(alpha - 1.0) < R_SMALL4) | ||||
alpha = 1.0F; | ||||
if(ray) { | if(ray) { | |||
int variable_alpha = I->VariableAlphaFlag; | #ifndef _PYMOL_NO_RAY | |||
ray->transparentf(1.0F - alpha); | CGORenderRay(I->primitiveCGO, ray, info, NULL, NULL, I->R.cs->Setting, I->R. | |||
v = I->VC; | obj->Setting); | |||
c = I->NC; | #endif | |||
while(ok && c--) { | ||||
if(variable_alpha) { | ||||
ray->transparentf(1.0F - v[3]); | ||||
} | ||||
ray->color3fv(v); | ||||
v += 4; | ||||
ok &= ray->sphere3fv(v, *(v + 3)); | ||||
v += 4; | ||||
} | ||||
ray->transparentf(0.0); | ||||
} else if(G->HaveGUI && G->ValidContext) { | } else if(G->HaveGUI && G->ValidContext) { | |||
if(pick) { | if(pick) { | |||
if (I->shaderCGO){ | ||||
i = (*pick)->src.index; | CGORenderGLPicking(I->shaderCGO, info, &I->R.context, I->R.cs->Setting, I | |||
->R.obj->Setting); | ||||
v = I->VP; | } else if (I->primitiveCGO){ | |||
c = I->NP; | CGORenderGLPicking(I->primitiveCGO, info, &I->R.context, I->R.cs->Setting | |||
p = I->R.P; | , I->R.obj->Setting); | |||
SceneSetupGLPicking(G); | ||||
glBegin(GL_LINES); | ||||
while(c--) { | ||||
i++; | ||||
if(!(*pick)[0].src.bond) { | ||||
/* pass 1 - low order bits */ | ||||
glColor3ub((uchar) ((i & 0xF) << 4), (uchar) ((i & 0xF0) | 0x8), | ||||
(uchar) ((i & 0xF00) >> 4)); | ||||
VLACheck((*pick), Picking, i); | ||||
p++; | ||||
(*pick)[i].src = *p; /* copy object and atom info */ | ||||
(*pick)[i].context = I->R.context; | ||||
} else { | ||||
/* pass 2 - high order bits */ | ||||
j = i >> 12; | ||||
glColor3ub((uchar) ((j & 0xF) << 4), (uchar) ((j & 0xF0) | 0x8), | ||||
(uchar) ((j & 0xF00) >> 4)); | ||||
} | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
} | } | |||
glEnd(); | ||||
(*pick)[0].src.index = i; | ||||
} else { /* rendering */ | } else { /* rendering */ | |||
int variable_alpha = I->VariableAlphaFlag; | short use_shader, use_sphere_shader; | |||
short use_shader, use_default_shader, use_sphere_shader, generate_shader_c | ||||
go = 0; | ||||
use_shader = SettingGetGlobal_i(G, cSetting_nb_spheres_use_shader) && | use_shader = SettingGetGlobal_i(G, cSetting_nb_spheres_use_shader) && | |||
SettingGetGlobal_b(G, cSetting_use_shaders); | SettingGetGlobal_b(G, cSetting_use_shaders); | |||
use_sphere_shader = (SettingGetGlobal_i(G, cSetting_nb_spheres_use_shader) ==1) && | use_sphere_shader = (SettingGetGlobal_i(G, cSetting_nb_spheres_use_shader) ==1) && | |||
SettingGetGlobal_b(G, cSetting_use_shaders); | SettingGetGlobal_b(G, cSetting_use_shaders); | |||
use_default_shader = (SettingGetGlobal_i(G, cSetting_nb_spheres_use_shader | ||||
)==2) && | ||||
SettingGetGlobal_b(G, cSetting_use_shaders); | ||||
if (I->shaderCGO){ | if (I->shaderCGO){ | |||
if (!use_shader || use_sphere_shader ^ I->shaderCGO->has_draw_sphere_buff ers){ | if (!use_shader || use_sphere_shader ^ I->shaderCGO->has_draw_sphere_buff ers){ | |||
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); | if (use_sphere_shader){ | |||
CHECKOK(ok, I->shaderCGO); | I->shaderCGO = CGOOptimizeSpheresToVBONonIndexed(I->primitiveCGO, 0, | |||
if (ok) | true); | |||
I->shaderCGO->use_shader = true; | } else { | |||
generate_shader_cgo = 1; | ok_assert(1, I->shaderCGO = CGOSimplify(I->primitiveCGO, 0, SettingG | |||
} else if (ok) { | et_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_nb_spheres_quality))); | |||
I->shaderCGO->enable_shaders = true; | ok_assert(1, CGOCombineBeginEnd(&I->shaderCGO)); | |||
CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); | ok_assert(1, CGOOptimizeToVBONotIndexed(&I->shaderCGO)); | |||
return; | } | |||
} | I->shaderCGO->use_shader = true; | |||
} | ||||
sp = I->SP; | ||||
if (generate_shader_cgo){ | ||||
if (ok){ | ||||
if (use_sphere_shader){ | ||||
/* Go through the ray tracing data, its easier (and available!) */ | ||||
int variable_alpha = I->VariableAlphaFlag; | ||||
ok &= CGOAlpha(I->shaderCGO, alpha); | ||||
v = I->VC; | ||||
c = I->NC; | ||||
while(ok && c--) { | ||||
if(variable_alpha) { | ||||
ok &= CGOAlpha(I->shaderCGO, v[3]); | ||||
} | ||||
if (ok){ | ||||
ok &= CGOColorv(I->shaderCGO, v); | ||||
v += 4; | ||||
} | ||||
if (ok){ | ||||
ok &= CGOSphere(I->shaderCGO, v, *(v + 3)); | ||||
v += 4; | ||||
} | ||||
} | ||||
if (ok) | ||||
ok &= CGOAlpha(I->shaderCGO, 1.); | ||||
} else { | ||||
while(ok && c--) { | ||||
if((alpha == 1.0) && (!variable_alpha)) { | ||||
ok &= CGOAlpha(I->shaderCGO, 1.f); | ||||
if (ok) | ||||
ok &= CGOColorv(I->shaderCGO, v); | ||||
} else { | ||||
if(variable_alpha) | ||||
ok &= CGOAlpha(I->shaderCGO, v[3]); | ||||
else | ||||
ok &= CGOAlpha(I->shaderCGO, alpha); | ||||
if (ok) | ||||
ok &= CGOColor(I->shaderCGO, v[0], v[1], v[2]); | ||||
} | ||||
v += 4; | ||||
for(a = 0; ok && a < sp->NStrip; a++) { | ||||
cc = sp->StripLen[a]; | ||||
ok &= CGOBegin(I->shaderCGO, GL_TRIANGLE_STRIP); | ||||
while(ok && cc--) { | ||||
ok &= CGONormalv(I->shaderCGO, v); | ||||
v += 3; | ||||
if (ok){ | ||||
ok &= CGOVertexv(I->shaderCGO, v); | ||||
v += 3; | ||||
} | ||||
} | ||||
if (ok) | ||||
ok &= CGOEnd(I->shaderCGO); | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} else { | ||||
while(c--) { | ||||
if((alpha == 1.0) && (!variable_alpha)) { | ||||
glColor3fv(v); | ||||
} else { | ||||
if(variable_alpha) | ||||
glColor4f(v[0], v[1], v[2], v[3]); | ||||
else | ||||
glColor4f(v[0], v[1], v[2], alpha); | ||||
} | ||||
v += 4; | ||||
for(a = 0; a < sp->NStrip; a++) { | ||||
cc = sp->StripLen[a]; | ||||
#ifdef PURE_OPENGL_ES_2 | ||||
/* TODO */ | ||||
#else | ||||
glBegin(GL_TRIANGLE_STRIP); | ||||
while(cc--) { | ||||
glNormal3fv(v); | ||||
v += 3; | ||||
glVertex3fv(v); | ||||
v += 3; | ||||
} | ||||
glEnd(); | ||||
#endif | ||||
} | ||||
} | } | |||
} | CGORenderGL(I->shaderCGO, NULL, I->R.cs->Setting, I->R.obj->Setting, inf | |||
o, &I->R); | ||||
if (use_shader) { | } else { | |||
if (ok && generate_shader_cgo){ | CGORenderGL(I->primitiveCGO, NULL, I->R.cs->Setting, I->R.obj->Setting, | |||
CGO *convertcgo = NULL; | info, &I->R); | |||
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 (use_sphere_shader){ | ||||
convertcgo = CGOOptimizeSpheresToVBONonIndexed(I->shaderCGO, 0); | ||||
} else { | ||||
convertcgo = CGOOptimizeToVBONotIndexed(I->shaderCGO, 0); | ||||
} | ||||
CHECKOK(ok, convertcgo); | ||||
} | ||||
if(convertcgo){ | ||||
CGOFree(I->shaderCGO); | ||||
I->shaderCGO = convertcgo; | ||||
I->shaderCGO->use_shader = true; | ||||
convertcgo = NULL; | ||||
} | ||||
} | ||||
if (ok) { | ||||
I->shaderCGO->enable_shaders = true; | ||||
CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); | ||||
return; | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
if (!ok){ | return; | |||
CGOFree(I->shaderCGO); | ok_except1: | |||
I->shaderCGO = NULL; | CGOFree(I->shaderCGO); | |||
I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge); | I->R.fInvalidate(&I->R, I->R.cs, cRepInvPurge); | |||
I->R.cs->Active[cRepNonbondedSphere] = false; | I->R.cs->Active[cRepNonbondedSphere] = false; | |||
} | ||||
} | } | |||
Rep *RepNonbondedSphereNew(CoordSet * cs, int state) | Rep *RepNonbondedSphereNew(CoordSet * cs, int state) | |||
{ | { | |||
PyMOLGlobals *G = cs->State.G; | PyMOLGlobals *G = cs->State.G; | |||
ObjectMolecule *obj = cs->Obj; | ObjectMolecule *obj = cs->Obj; | |||
int a, c, d, c1; | ||||
float *v, *v0, *vc; | unsigned char *active = NULL; | |||
float nb_spheres_size; | ||||
int *q, *s; | ||||
SphereRec *sp = G->Sphere->Sphere[0]; | ||||
int nb_spheres_quality; | ||||
int *active = NULL; | ||||
AtomInfoType *ai; | ||||
int nSphere = 0; | int nSphere = 0; | |||
int a1; | ||||
float *v1; | ||||
float tmpColor[3]; | ||||
int variable_alpha = false; | ||||
float transp = | float transp = | |||
SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_nonbonded_transparen cy); | 1.f - SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_nonbonded_tran sparency); | |||
int ok = true; | int ok = true; | |||
OOAlloc(G, RepNonbondedSphere); | OOAlloc(G, RepNonbondedSphere); | |||
CHECKOK(ok, I); | CHECKOK(ok, I); | |||
if (ok) | if (ok) | |||
active = Alloc(int, cs->NIndex); | active = Alloc(unsigned char, cs->NIndex); | |||
CHECKOK(ok, active); | CHECKOK(ok, active); | |||
if((obj->RepVisCache & cRepNonbondedSphereBit)) | if((obj->RepVisCache & cRepNonbondedSphereBit)){ | |||
for(a = 0; a < cs->NIndex; a++) { | for(int a = 0; a < cs->NIndex; a++) { | |||
ai = obj->AtomInfo + cs->IdxToAtm[a]; | AtomInfoType *ai = obj->AtomInfo + cs->IdxToAtm[a]; | |||
active[a] = (!ai->bonded && (ai->visRep & cRepNonbondedSphereBit)); | active[a] = (!ai->bonded && (ai->visRep & cRepNonbondedSphereBit)); | |||
if(active[a]) { | if (active[a]) | |||
active[a] = (ai->masked) ? -1 : 1; | ||||
nSphere++; | nSphere++; | |||
} | ||||
} | } | |||
} | ||||
if(!nSphere) { | if(!nSphere) { | |||
OOFreeP(I); | OOFreeP(I); | |||
FreeP(active); | FreeP(active); | |||
return (NULL); /* skip if no dots are visible */ | return (NULL); | |||
} | } | |||
float nb_spheres_size = | ||||
nb_spheres_size = | ||||
SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_nb_spheres_size); | SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_nb_spheres_size); | |||
/* get current dot sampling */ | ||||
nb_spheres_quality = SettingGet_i(G, cs->Setting, obj->Obj.Setting, cSetting_n | ||||
b_spheres_quality); | ||||
if(nb_spheres_quality < 0) | ||||
nb_spheres_quality = 0; | ||||
if(nb_spheres_quality > (NUMBER_OF_SPHERE_LEVELS-1)) | ||||
nb_spheres_quality = NUMBER_OF_SPHERE_LEVELS-1; | ||||
sp = G->Sphere->Sphere[nb_spheres_quality]; | ||||
RepInit(G, &I->R); | RepInit(G, &I->R); | |||
I->R.fRender = (void (*)(struct Rep *, RenderInfo *)) RepNonbondedSphereRender ; | I->R.fRender = (void (*)(struct Rep *, RenderInfo *)) RepNonbondedSphereRender ; | |||
I->R.fFree = (void (*)(struct Rep *)) RepNonbondedSphereFree; | I->R.fFree = (void (*)(struct Rep *)) RepNonbondedSphereFree; | |||
I->R.fRecolor = NULL; | I->R.fRecolor = NULL; | |||
I->R.obj = (CObject *) (cs->Obj); | I->R.obj = (CObject *) (cs->Obj); | |||
I->R.cs = cs; | I->R.cs = cs; | |||
I->shaderCGO = NULL; | I->shaderCGO = NULL; | |||
I->N = 0; | I->primitiveCGO = NULL; | |||
I->NC = 0; | ||||
I->V = NULL; | ||||
I->VC = NULL; | ||||
I->SP = NULL; | ||||
I->NP = 0; | ||||
I->VP = NULL; | ||||
I->R.P = NULL; | ||||
/* raytracing primitives */ | ||||
I->VC = (float *) mmalloc(sizeof(float) * nSphere * 8); | ||||
CHECKOK(ok, I->VC); | ||||
I->NC = 0; | ||||
v = I->VC; | ||||
for(a = 0; ok && a < cs->NIndex; a++) { | ||||
if(active[a]) { | ||||
float at_transp = transp; | ||||
ai = obj->AtomInfo + cs->IdxToAtm[a]; | ||||
if(AtomSettingGetIfDefined(G, ai, cSetting_nonbonded_transparency, &at_tra | ||||
nsp)) | ||||
variable_alpha = true; | ||||
I->NC++; | ||||
c1 = ai->color; | ||||
v0 = cs->Coord + 3 * a; | ||||
if(ColorCheckRamped(G, c1)) { | ||||
ColorGetRamped(G, c1, v0, tmpColor, state); | ||||
vc = tmpColor; | ||||
} else { | ||||
vc = ColorGet(G, c1); | ||||
} | ||||
*(v++) = *(vc++); | ||||
*(v++) = *(vc++); | ||||
*(v++) = *(vc++); | ||||
*(v++) = 1.0F - at_transp; | ||||
*(v++) = *(v0++); | ||||
*(v++) = *(v0++); | ||||
*(v++) = *(v0++); | ||||
*(v++) = nb_spheres_size; | ||||
} | ||||
ok &= !G->Interrupt; | ||||
} | ||||
if (ok){ | ||||
I->VariableAlphaFlag = variable_alpha; | ||||
if(I->NC) | ||||
I->VC = ReallocForSure(I->VC, float, (v - I->VC)); | ||||
else | ||||
I->VC = ReallocForSure(I->VC, float, 1); | ||||
CHECKOK(ok, I->VC); | ||||
} | ||||
if (ok) | ||||
I->V = (float *) mmalloc(sizeof(float) * nSphere * (4 + sp->NVertTot * 6)); | ||||
CHECKOK(ok, I->V); | ||||
/* rendering primitives */ | /* Generate primitiveCGO */ | |||
float at_transp; | ||||
I->N = 0; | int NP = 0; | |||
I->SP = sp; | bool alpha_set = false; | |||
v = I->V; | I->primitiveCGO = CGONew(G); | |||
CGOAlpha(I->primitiveCGO, transp); | ||||
for(a = 0; ok && a < cs->NIndex; a++) { | for(int a = 0; ok && a < cs->NIndex; a++){ | |||
if(active[a]) { | if(active[a]) { | |||
float at_transp = transp; | int a1 = cs->IdxToAtm[a]; | |||
ai = obj->AtomInfo + cs->IdxToAtm[a]; | AtomInfoType *ai = obj->AtomInfo + a1; | |||
c1 = ai->color; | NP++; | |||
v0 = cs->Coord + 3 * a; | const float *v1 = cs->Coord + 3 * a; | |||
vc = ColorGet(G, c1); | int c1 = ai->color; | |||
const float *vc; | ||||
if(AtomSettingGetIfDefined(G, ai, cSetting_nonbonded_transparency, &at_tra | ||||
nsp)) | ||||
variable_alpha = true; | ||||
if(ColorCheckRamped(G, c1)) { | if(ColorCheckRamped(G, c1)) { | |||
ColorGetRamped(G, c1, v0, tmpColor, state); | float tmpColor[3]; | |||
vc = tmpColor; | ColorGetRamped(G, c1, v1, tmpColor, state); | |||
vc = tmpColor; | ||||
} else { | } else { | |||
vc = ColorGet(G, c1); | vc = ColorGet(G, c1); | |||
} | } | |||
CGOPickColor(I->primitiveCGO, a1, (ai->masked ? cPickableNoPick : cPickabl | ||||
*(v++) = *(vc++); | eAtom)); | |||
*(v++) = *(vc++); | if(AtomSettingGetIfDefined(G, ai, cSetting_nonbonded_transparency, &at_tra | |||
*(v++) = *(vc++); | nsp)){ | |||
*(v++) = 1.0F - at_transp; | CGOAlpha(I->primitiveCGO, 1.f - at_transp); | |||
alpha_set = true; | ||||
q = sp->Sequence; | } else if (alpha_set){ | |||
s = sp->StripLen; | /* if atom level transparency is set, and this atom doesn't have transpa | |||
rency, | ||||
for(d = 0; ok && d < sp->NStrip; d++) { | then set back to object-level transparency */ | |||
for(c = 0; c < (*s); c++) { | CGOAlpha(I->primitiveCGO, transp); | |||
*(v++) = sp->dot[*q][0]; /* normal */ | alpha_set = false; | |||
*(v++) = sp->dot[*q][1]; | ||||
*(v++) = sp->dot[*q][2]; | ||||
*(v++) = v0[0] + nb_spheres_size * sp->dot[*q][0]; /* point */ | ||||
*(v++) = v0[1] + nb_spheres_size * sp->dot[*q][1]; | ||||
*(v++) = v0[2] + nb_spheres_size * sp->dot[*q][2]; | ||||
q++; | ||||
} | ||||
s++; | ||||
ok &= !G->Interrupt; | ||||
} | } | |||
I->N++; | CGOColorv(I->primitiveCGO, vc); | |||
CGOSphere(I->primitiveCGO, v1, nb_spheres_size); | ||||
} | } | |||
ok &= !G->Interrupt; | ||||
} | } | |||
CGOStop(I->primitiveCGO); | ||||
I->primitiveCGO->sphere_quality = SettingGet_i(G, cs->Setting, obj->Obj.Settin | ||||
g, cSetting_nb_spheres_quality); | ||||
if (ok){ | if (ok){ | |||
if(I->N) | I->R.context.object = (void *) obj; | |||
I->V = ReallocForSure(I->V, float, (v - I->V)); | I->R.context.state = state; | |||
else | ||||
I->V = ReallocForSure(I->V, float, 1); | ||||
CHECKOK(ok, I->V); | ||||
} | } | |||
/* use pickable representation from nonbonded */ | ||||
if(ok && SettingGet_f(G, cs->Setting, obj->Obj.Setting, cSetting_pickable)) { | ||||
I->VP = (float *) mmalloc(sizeof(float) * nSphere * 18); | ||||
CHECKOK(ok, I->VP); | ||||
if (ok) | ||||
I->R.P = Alloc(Pickable, cs->NIndex + 1); | ||||
CHECKOK(ok, I->R.P); | ||||
v = I->VP; | ||||
for(a = 0; ok && a < cs->NIndex; a++){ | ||||
if(active[a] > 0) { | ||||
a1 = cs->IdxToAtm[a]; | ||||
if(!obj->AtomInfo[a1].masked) { | ||||
I->NP++; | ||||
I->R.P[I->NP].index = a1; | ||||
I->R.P[I->NP].bond = -1; | ||||
v1 = cs->Coord + 3 * a; | ||||
*(v++) = v1[0] - nb_spheres_size; | ||||
*(v++) = v1[1]; | ||||
*(v++) = v1[2]; | ||||
*(v++) = v1[0] + nb_spheres_size; | ||||
*(v++) = v1[1]; | ||||
*(v++) = v1[2]; | ||||
*(v++) = v1[0]; | ||||
*(v++) = v1[1] - nb_spheres_size; | ||||
*(v++) = v1[2]; | ||||
*(v++) = v1[0]; | ||||
*(v++) = v1[1] + nb_spheres_size; | ||||
*(v++) = v1[2]; | ||||
*(v++) = v1[0]; | ||||
*(v++) = v1[1]; | ||||
*(v++) = v1[2] - nb_spheres_size; | ||||
*(v++) = v1[0]; | ||||
*(v++) = v1[1]; | ||||
*(v++) = v1[2] + nb_spheres_size; | ||||
} | ||||
} | ||||
ok &= !G->Interrupt; | ||||
} | ||||
if (ok) | ||||
I->R.P = Realloc(I->R.P, Pickable, I->NP + 1); | ||||
CHECKOK(ok, I->R.P); | ||||
if (ok){ | ||||
I->R.context.object = (void *) obj; | ||||
I->R.context.state = state; | ||||
I->R.P[0].index = I->NP; | ||||
} | ||||
if (ok) | ||||
I->VP = Realloc(I->VP, float, I->NP * 21); | ||||
CHECKOK(ok, I->VP); | ||||
} | ||||
FreeP(active); | FreeP(active); | |||
if (!ok){ | if (!ok){ | |||
RepNonbondedSphereFree(I); | RepNonbondedSphereFree(I); | |||
I = NULL; | I = NULL; | |||
} | } | |||
return (Rep *) I; | return (Rep *) I; | |||
} | } | |||
End of changes. 35 change blocks. | ||||
420 lines changed or deleted | 85 lines changed or added |