diff --git a/layer1/Setting.cpp b/layer1/Setting.cpp index 6cafac36f..bd3382f32 100644 --- a/layer1/Setting.cpp +++ b/layer1/Setting.cpp @@ -2481,6 +2481,9 @@ void SettingGenerateSideEffects(PyMOLGlobals * G, int index, const char *sele, i ExecutiveInvalidateRep(G, inv_sele, cRepSphere, cRepInvRep); SceneInvalidate(G); break; + case cSetting_cell_color: + ExecutiveInvalidateRep(G, inv_sele, cRepCell, cRepInvColor); + SceneInvalidate(G); case cSetting_cull_spheres: case cSetting_sphere_scale: case cSetting_sphere_transparency: diff --git a/layer1/SettingInfo.h b/layer1/SettingInfo.h index 83f589250..a905aa3eb 100644 --- a/layer1/SettingInfo.h +++ b/layer1/SettingInfo.h @@ -904,6 +904,7 @@ enum { REC_f( 794, halogen_bond_as_acceptor_max_acceptor_angle , global , 170.0f ), REC_f( 795, salt_bridge_distance , global , 5.0f ), REC_b( 796, use_tessellation_shaders , global , true ), + REC_c( 797, cell_color , ostate , "-1" ), #ifdef SETTINGINFO_IMPLEMENTATION #undef SETTINGINFO_IMPLEMENTATION diff --git a/layer2/CoordSet.cpp b/layer2/CoordSet.cpp index cfa3a351c..7eab88129 100644 --- a/layer2/CoordSet.cpp +++ b/layer2/CoordSet.cpp @@ -1287,7 +1287,12 @@ void CoordSet::update(int state) UnitCellCGO.reset(CrystalGetUnitCellCGO(&sym->Crystal)); auto use_shader = SettingGet(G, cSetting_use_shaders); if (use_shader) { - auto color = ColorGet(G, Obj->Color); + auto cell_color = SettingGet_color( + G, this->Setting.get(), Obj->Setting.get(), cSetting_cell_color); + if (cell_color < 0) { + cell_color = Obj->Color; + } + auto color = ColorGet(G, cell_color); auto preCGO = std::make_unique(G); CGOColorv(preCGO.get(), color); CGOAppendNoStop(preCGO.get(), UnitCellCGO.get()); diff --git a/layer2/ObjectSurface.cpp b/layer2/ObjectSurface.cpp index 3a8e90762..5080ba886 100644 --- a/layer2/ObjectSurface.cpp +++ b/layer2/ObjectSurface.cpp @@ -870,7 +870,12 @@ static void ObjectSurfaceRenderCell(PyMOLGlobals *G, ObjectSurface * I, * TODO: Ray with primitive CGO */ - const float *color = ColorGet(G, I->Color); + // TODO: Surface-state level color? + auto cell_color = SettingGet_color(*I, cSetting_cell_color); + if (cell_color < 0) { + cell_color = I->Color; + } + const float *color = ColorGet(G, cell_color); if (use_shader != ms->UnitCellCGO->has_draw_buffers){ if (use_shader){ auto preCGO = std::make_unique(G);