From a5985ec9c79a7f695fa63a6c77cb6a876ca6dad6 Mon Sep 17 00:00:00 2001
From: Marco Biasini <marco.biasini@unibas.ch>
Date: Thu, 21 Apr 2011 12:53:43 +0200
Subject: [PATCH] don't mark XCS dirty when applying a transform to an entity

It is completely sufficient to mark the organizer dirty. Fixes
BZDNG-250.
---
 modules/mol/base/src/impl/entity_impl.cc |  3 ++-
 modules/mol/base/tests/test_entity.cc    | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/mol/base/src/impl/entity_impl.cc b/modules/mol/base/src/impl/entity_impl.cc
index eb85cef79..4e311ddc0 100644
--- a/modules/mol/base/src/impl/entity_impl.cc
+++ b/modules/mol/base/src/impl/entity_impl.cc
@@ -770,7 +770,7 @@ void EntityImpl::SetTransform(const geom::Mat4 transfmat)
     identity_transf_ = false;    
   }
   this->UpdateTransformedPos();
-  this->MarkXCSDirty();
+  this->MarkOrganizerDirty();
 }
 
 void EntityImpl::AttachObserver(const EntityObserverPtr& o)
@@ -1049,6 +1049,7 @@ void EntityImpl::UpdateOrganizer()
        e=atom_map_.end(); i!=e; ++i) {
     atom_organizer_.Add(i->second, i->second->GetPos());
   }
+  dirty_flags_&=~DirtyOrganizer;
 }
 
 void EntityImpl::IncXCSEditorCount() 
diff --git a/modules/mol/base/tests/test_entity.cc b/modules/mol/base/tests/test_entity.cc
index 646b75f74..0c6bbe13a 100644
--- a/modules/mol/base/tests/test_entity.cc
+++ b/modules/mol/base/tests/test_entity.cc
@@ -98,6 +98,16 @@ BOOST_AUTO_TEST_CASE(throw_invalid_ent_view)
   BOOST_CHECK_NO_THROW(CheckHandleValidity(ent.CreateEmptyView()));
 }
 
+BOOST_AUTO_TEST_CASE(bzdng250)
+{
+  EntityHandle eh=make_test_entity();
+  eh.EditXCS().ApplyTransform(geom::Mat4(-1, 0, 0, 0,
+                                          0, 1, 0, 0,
+                                          0, 0,-1, 0,
+                                          0, 0, 0, 1));
+  BOOST_CHECK_NO_THROW(eh.FindResidue("A", 1).FindTorsion("PHI").GetAngle());
+}
+
 BOOST_AUTO_TEST_CASE(entity_creator) 
 {
   EntityHandle eh = CreateEntity();
-- 
GitLab