ObjectMesh.cpp (pymol-v2.1.0.tar.bz2) | : | ObjectMesh.cpp (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 498 | skipping to change at line 498 | |||
if(new_color != cur_color) { | if(new_color != cur_color) { | |||
one_color_flag = false; | one_color_flag = false; | |||
cur_color = new_color; | cur_color = new_color; | |||
} | } | |||
} | } | |||
if(ColorCheckRamped(I->Obj.G, cur_color)) { | if(ColorCheckRamped(I->Obj.G, cur_color)) { | |||
ColorGetRamped(I->Obj.G, cur_color, v, vc, state); | ColorGetRamped(I->Obj.G, cur_color, v, vc, state); | |||
*rc = cur_color; | *rc = cur_color; | |||
ramped_flag = true; | ramped_flag = true; | |||
} else { | } else { | |||
float *col = ColorGet(I->Obj.G, cur_color); | const float *col = ColorGet(I->Obj.G, cur_color); | |||
copy3f(col, vc); | copy3f(col, vc); | |||
} | } | |||
rc++; | rc++; | |||
vc += 3; | vc += 3; | |||
v += 3; | v += 3; | |||
} | } | |||
} | } | |||
if(one_color_flag && (!ramped_flag)) { | if(one_color_flag && (!ramped_flag)) { | |||
FreeP(ms->VC); | FreeP(ms->VC); | |||
skipping to change at line 788 | skipping to change at line 788 | |||
{ | { | |||
ObjectMeshRenderImpl(I, info, 0, 0); | ObjectMeshRenderImpl(I, info, 0, 0); | |||
} | } | |||
static short ObjectMeshStateRenderShader(ObjectMeshState *ms, ObjectMesh *I, | static short ObjectMeshStateRenderShader(ObjectMeshState *ms, ObjectMesh *I, | |||
RenderInfo *info, short mesh_as_cylinders, float mesh_width) | RenderInfo *info, short mesh_as_cylinders, float mesh_width) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
CShaderPrg *shaderPrg; | CShaderPrg *shaderPrg; | |||
if (mesh_as_cylinders) { | if (!mesh_as_cylinders) { | |||
shaderPrg = CShaderPrg_Enable_CylinderShader(G); | shaderPrg = G->ShaderMgr->Enable_DefaultShader(info->pass); | |||
CShaderPrg_Set1f(shaderPrg, "uni_radius", | shaderPrg->SetLightingEnabled(0); | |||
SceneGetLineWidthForCylinders(G, info, mesh_width)); | shaderPrg->Set1i("two_sided_lighting_enabled", | |||
} else { | ||||
shaderPrg = CShaderPrg_Enable_DefaultShader(G); | ||||
CShaderPrg_SetLightingEnabled(shaderPrg, 1); | ||||
CShaderPrg_Set1i(shaderPrg, "two_sided_lighting_enabled", | ||||
SceneGetTwoSidedLighting(G)); | SceneGetTwoSidedLighting(G)); | |||
} | ||||
if (!shaderPrg) | if (!shaderPrg) | |||
return false; | return false; | |||
} | ||||
CGORenderGL(ms->shaderCGO, NULL, NULL, NULL, info, NULL); | CGORenderGL(ms->shaderCGO, NULL, NULL, NULL, info, NULL); | |||
CShaderPrg_Disable(shaderPrg); | ||||
if (ms->shaderUnitCellCGO){ | if (ms->shaderUnitCellCGO){ | |||
shaderPrg = CShaderPrg_Enable_DefaultShader(G); | shaderPrg = G->ShaderMgr->Enable_DefaultShader(info->pass); | |||
CShaderPrg_SetLightingEnabled(shaderPrg, 0); | shaderPrg->SetLightingEnabled(0); | |||
CGORenderGL(ms->shaderUnitCellCGO, NULL, NULL, NULL, info, NULL); | CGORenderGL(ms->shaderUnitCellCGO, NULL, NULL, NULL, info, NULL); | |||
CShaderPrg_Disable(shaderPrg); | shaderPrg->Disable(); | |||
} | } | |||
return true; | return true; | |||
} | } | |||
static CGO *ObjectMeshRenderImpl(ObjectMesh * I, RenderInfo * info, int returnCG O, int stateArg) | static CGO *ObjectMeshRenderImpl(ObjectMesh * I, RenderInfo * info, int returnCG O, int stateArg) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
float *v = NULL; | float *v = NULL; | |||
float *vc; | float *vc; | |||
skipping to change at line 842 | skipping to change at line 836 | |||
if (info){ | if (info){ | |||
state = info->state; | state = info->state; | |||
ray = info->ray; | ray = info->ray; | |||
pick = info->pick; | pick = info->pick; | |||
pass = info->pass; | pass = info->pass; | |||
} else { | } else { | |||
state = stateArg; | state = stateArg; | |||
} | } | |||
line_width = SceneGetDynamicLineWidth(info, mesh_width); | line_width = SceneGetDynamicLineWidth(info, mesh_width); | |||
ObjectPrepareContext(&I->Obj, ray); | ObjectPrepareContext(&I->Obj, info); | |||
for(StateIterator iter(I->Obj.G, I->Obj.Setting, state, I->NState); iter.next( );) { | for(StateIterator iter(I->Obj.G, I->Obj.Setting, state, I->NState); iter.next( );) { | |||
ms = I->State + iter.state; | ms = I->State + iter.state; | |||
if(!ms->Active || !ms->V || !ms->N) | if(!ms->Active || !ms->V || !ms->N) | |||
continue; | continue; | |||
{ | { | |||
v = ms->V; | v = ms->V; | |||
n = ms->N; | n = ms->N; | |||
if(ok && ray) { | if(ok && ray) { | |||
if(ms->UnitCellCGO && (I->Obj.visRep & cRepCellBit)){ | if(ms->UnitCellCGO && (I->Obj.visRep & cRepCellBit)){ | |||
ok &= CGORenderRay(ms->UnitCellCGO, ray, ColorGet(I->Obj.G, I->Obj.C | ok &= CGORenderRay(ms->UnitCellCGO, ray, info, ColorGet(I->Obj.G, I- | |||
olor), | >Obj.Color), | |||
I->Obj.Setting, NULL); | NULL, I->Obj.Setting, NULL); | |||
if (!ok){ | if (!ok){ | |||
CGOFree(ms->UnitCellCGO); | CGOFree(ms->UnitCellCGO); | |||
break; | break; | |||
} | } | |||
} | } | |||
if(ms->MeshMode != 1) { | if(ms->MeshMode != 1) { | |||
radius = SettingGet_f(I->Obj.G, I->Obj.Setting, NULL, cSetting_mesh_ radius); | radius = SettingGet_f(I->Obj.G, I->Obj.Setting, NULL, cSetting_mesh_ radius); | |||
if(radius == 0.0F) { | if(radius == 0.0F) { | |||
radius = ray->PixelRadius * line_width / 2.0F; | radius = ray->PixelRadius * line_width / 2.0F; | |||
skipping to change at line 963 | skipping to change at line 957 | |||
if (use_shader){ | if (use_shader){ | |||
shaderCGO = CGONew(G); | shaderCGO = CGONew(G); | |||
if(!shaderCGO) { | if(!shaderCGO) { | |||
ok = false; | ok = false; | |||
break; | break; | |||
} | } | |||
shaderCGO->use_shader = true; | shaderCGO->use_shader = true; | |||
} | } | |||
if(ms->UnitCellCGO && (I->Obj.visRep & cRepCellBit)) { | if(ms->UnitCellCGO && (I->Obj.visRep & cRepCellBit)) { | |||
float *color = ColorGet(I->Obj.G, I->Obj.Color); | const float *color = ColorGet(I->Obj.G, I->Obj.Color); | |||
if (!use_shader) { | if (!use_shader) { | |||
CGORenderGL(ms->UnitCellCGO, color, I->Obj.Setting, NULL, info, NULL); | CGORenderGL(ms->UnitCellCGO, color, I->Obj.Setting, NULL, info, NULL); | |||
} else if(!ms->shaderUnitCellCGO) { | } else if(!ms->shaderUnitCellCGO) { | |||
CGO *newUnitCellCGO = CGONewSized(G, 0); | CGO *newUnitCellCGO = CGONewSized(G, 0); | |||
CGOColorv(newUnitCellCGO, color); | CGOColorv(newUnitCellCGO, color); | |||
CGOAppend(newUnitCellCGO, ms->UnitCellCGO); | CGOAppend(newUnitCellCGO, ms->UnitCellCGO); | |||
ms->shaderUnitCellCGO = CGOOptimizeToVBONotIndexed(newUnitCellC GO, 0); | ms->shaderUnitCellCGO = CGOOptimizeToVBONotIndexedNoShader(newU nitCellCGO, 0); | |||
CGOFree(newUnitCellCGO); | CGOFree(newUnitCellCGO); | |||
ms->shaderUnitCellCGO->use_shader = true; | ms->shaderUnitCellCGO->use_shader = true; | |||
ms->shaderUnitCellCGO->enable_shaders = false; | ||||
} | } | |||
} | } | |||
if(info && !info->line_lighting){ | if(info && !info->line_lighting){ | |||
if(!use_shader){ | if(!use_shader){ | |||
glDisable(GL_LIGHTING); | glDisable(GL_LIGHTING); | |||
} else if(!mesh_as_cylinders) { | } else if(!mesh_as_cylinders) { | |||
ok &= CGODisable(shaderCGO, GL_LIGHTING); | ok &= CGODisable(shaderCGO, GL_LIGHTING); | |||
} | } | |||
} | } | |||
if(!ok) break; | if(!ok) break; | |||
if (use_shader){ | if (use_shader){ | |||
ok &= CGOResetNormal(shaderCGO, false); | ok &= CGOResetNormal(shaderCGO, true); | |||
} else { | } else { | |||
SceneResetNormal(I->Obj.G, false); | SceneResetNormal(I->Obj.G, false); | |||
} | } | |||
if(n && v && (I->Obj.visRep & cRepMeshBit)) { | if(n && v && (I->Obj.visRep & cRepMeshBit)) { | |||
if(use_shader) { | if(use_shader) { | |||
vc = ms->VC; | vc = ms->VC; | |||
if(!vc) | if(!vc) | |||
ok &= CGOColorv(shaderCGO, ColorGet(I->Obj.G, ms->OneColor)); | ok &= CGOColorv(shaderCGO, ColorGet(I->Obj.G, ms->OneColor)); | |||
if (!mesh_as_cylinders){ | if (!mesh_as_cylinders){ | |||
if(ms->MeshMode == 1){ | if(ms->MeshMode == 1){ | |||
ok &= CGODotwidth(shaderCGO, SettingGet_f | ok &= CGODotwidth(shaderCGO, SettingGet_f | |||
(I->Obj.G, I->Obj.Setting, NULL, cSetting_dot_w idth)); | (I->Obj.G, I->Obj.Setting, NULL, cSetting_dot_w idth)); | |||
} else { | } else { | |||
ok &= CGOLinewidthSpecial(shaderCGO, LINEWIDTH_DYNAMIC_MESH ); | ok &= CGOSpecial(shaderCGO, LINEWIDTH_DYNAMIC_MESH); | |||
} | } | |||
} | } | |||
if(!ok) break; | if(!ok) break; | |||
if (mesh_as_cylinders){ | if (mesh_as_cylinders){ | |||
if(returnCGO) { | if(returnCGO) { | |||
ok &= CGOLinewidthSpecial(shaderCGO, CYLINDERWIDTH_DYNAMIC_ MESH); | ok &= CGOSpecial(shaderCGO, CYLINDERWIDTH_DYNAMIC_MESH); | |||
} | } | |||
for(; ok && (c = *(n++)); v += 3, vc && (vc += 3)) { | for(; ok && (c = *(n++)); v += 3, vc && (vc += 3)) { | |||
for(; ok && (--c); v += 3) { | for(; ok && (--c); v += 3) { | |||
float axis[] = { | float axis[] = { | |||
v[3] - v[0], | v[3] - v[0], | |||
v[4] - v[1], | v[4] - v[1], | |||
v[5] - v[2] | v[5] - v[2] | |||
}; | }; | |||
if(vc) { | if(vc) { | |||
ok &= CGOColorv(shaderCGO, vc); | ok &= CGOColorv(shaderCGO, vc); | |||
vc += 3; | vc += 3; | |||
} | } | |||
if(vc && memcmp(vc - 3, vc, sizeof(float) * 3)) { | if(vc && memcmp(vc - 3, vc, sizeof(float) * 3)) { | |||
ok &= CGOShaderCylinder2ndColor(shaderCGO, v, axis, 1. f, 15, vc); | ok &= (bool)shaderCGO->add<cgo::draw::shadercylinder2n dcolor>(shaderCGO, v, axis, 1.f, 15, vc); | |||
} else { | } else { | |||
ok &= CGOShaderCylinder(shaderCGO, v, axis, 1.f, 15); | ok &= (bool)shaderCGO->add<cgo::draw::shadercylinder>( v, axis, 1.f, 15); | |||
} | } | |||
} | } | |||
} | } | |||
} else { | } else { | |||
while(ok && *n) { | while(ok && *n) { | |||
c = *(n++); | c = *(n++); | |||
if(ms->MeshMode == 1) | if(ms->MeshMode == 1) | |||
ok &= CGOBegin(shaderCGO, GL_POINTS); | ok &= CGOBegin(shaderCGO, GL_POINTS); | |||
else { | else { | |||
if (c < 2){ | if (c < 2){ | |||
skipping to change at line 1066 | skipping to change at line 1059 | |||
} | } | |||
if (ok) | if (ok) | |||
ok &= CGOEnd(shaderCGO); | ok &= CGOEnd(shaderCGO); | |||
} | } | |||
} | } | |||
} else { | } else { | |||
vc = ms->VC; | vc = ms->VC; | |||
if(!vc) | if(!vc) | |||
glColor3fv(ColorGet(I->Obj.G, ms->OneColor)); | glColor3fv(ColorGet(I->Obj.G, ms->OneColor)); | |||
if(ms->MeshMode == 1){ | if(ms->MeshMode == 1){ | |||
glPointSize(SettingGet_f | glPointSize(SettingGet_f | |||
(I->Obj.G, I->Obj.Setting, NULL, cSetting_dot_wid th)); | (I->Obj.G, I->Obj.Setting, NULL, cSetting_dot_wid th)); | |||
} else { | } else { | |||
glLineWidth(line_width); | glLineWidth(line_width); | |||
} | } | |||
while(*n) { | while(*n) { | |||
c = *(n++); | c = *(n++); | |||
if(ms->MeshMode == 1) | if(ms->MeshMode == 1) | |||
glBegin(GL_POINTS); | glBegin(GL_POINTS); | |||
skipping to change at line 1116 | skipping to change at line 1108 | |||
CHECKOK(ok, convertcgo); | CHECKOK(ok, convertcgo); | |||
CGOFree(shaderCGO); | CGOFree(shaderCGO); | |||
shaderCGO = convertcgo; | shaderCGO = convertcgo; | |||
if (returnCGO){ | if (returnCGO){ | |||
return (shaderCGO); | return (shaderCGO); | |||
} else { | } else { | |||
ms->shaderCGO = shaderCGO; | ms->shaderCGO = shaderCGO; | |||
} | } | |||
if (ok){ | if (ok){ | |||
if (mesh_as_cylinders){ | if (mesh_as_cylinders){ | |||
convertcgo = CGOOptimizeGLSLCylindersToVBOIndexed(ms->shade | CGO *tmpCGO = CGONew(G); | |||
rCGO, 0); | ok &= CGOEnable(tmpCGO, GL_CYLINDER_SHADER); | |||
if (ok) ok &= CGOSpecial(tmpCGO, MESH_WIDTH_FOR_SURFACES); | ||||
convertcgo = CGOConvertShaderCylindersToCylinderShader(ms- | ||||
>shaderCGO, tmpCGO); | ||||
if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo); | ||||
if (ok) ok &= CGODisable(tmpCGO, GL_CYLINDER_SHADER); | ||||
if (ok) ok &= CGOStop(tmpCGO); | ||||
CGOFreeWithoutVBOs(convertcgo); | ||||
convertcgo = tmpCGO; | ||||
convertcgo->use_shader = convertcgo->has_draw_cylinder_buf | ||||
fers = true; | ||||
} else { | } else { | |||
convertcgo = CGOOptimizeToVBONotIndexed(ms->shaderCGO, 0); | convertcgo = CGOOptimizeToVBONotIndexedWithReturnedData(ms- >shaderCGO, 0, false, NULL); | |||
} | } | |||
CHECKOK(ok, convertcgo); | CHECKOK(ok, convertcgo); | |||
} | } | |||
if (convertcgo){ | if (convertcgo){ | |||
CGOFree(ms->shaderCGO); | CGOFree(ms->shaderCGO); | |||
ms->shaderCGO = convertcgo; | ms->shaderCGO = convertcgo; | |||
} | } | |||
} | } | |||
if(!ok) break; | if(!ok) break; | |||
End of changes. 20 change blocks. | ||||
31 lines changed or deleted | 33 lines changed or added |