From b9fd3da98d0d3a261df02598e2c2407c7bc8d73c Mon Sep 17 00:00:00 2001
From: Ansgar Philippsen <ansgar.philippsen@gmail.com>
Date: Tue, 22 Feb 2011 17:53:14 -0500
Subject: [PATCH] fixed default outline (again); fixed superfluous rebuild for
 hidden objects

---
 modules/gfx/pymod/__init__.py   |  2 +-
 modules/gfx/src/entity.cc       | 28 ++++++++++++++++------------
 modules/gfx/src/entity.hh       |  1 +
 modules/gfx/src/gfx_object.cc   |  4 ++++
 modules/gfx/src/vertex_array.cc |  4 ++--
 5 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/modules/gfx/pymod/__init__.py b/modules/gfx/pymod/__init__.py
index 4dfc0fd64..10afd277e 100644
--- a/modules/gfx/pymod/__init__.py
+++ b/modules/gfx/pymod/__init__.py
@@ -183,4 +183,4 @@ def _Match(scene, pattern="*"):
     return matches
   return GfxNodeListProxy(_Recurse("", Scene().root_node, pattern))
 
-SceneSingleton.__getitem__=_Match
+SceneSingleton.Match=_Match
diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc
index 317f74c53..fef28debb 100644
--- a/modules/gfx/src/entity.cc
+++ b/modules/gfx/src/entity.cc
@@ -75,7 +75,8 @@ Entity::Entity(const String& name,
   opacity_(1.0),
   blur_(false),
   blurf1_(1.0),
-  blurf2_(0.8)
+  blurf2_(0.8),
+  needs_update_(true)
 {
   init(RenderMode::SIMPLE);
 }
@@ -327,26 +328,29 @@ void Entity::CacheBoundingBox() const
 bool Entity::UpdateIfNeeded() const
 {
   bool updated=false;
-  for (RendererMap::iterator i=renderer_.begin(), 
-       e=renderer_.end(); i!=e; ++i) {
-    EntityRenderer* renderer =i->second;
-    if (renderer->IsDirty()) {
-      renderer->PrepareRendering();
-      updated=true;
+  if(IsVisible()) {
+    for (RendererMap::iterator i=renderer_.begin(), 
+           e=renderer_.end(); i!=e; ++i) {
+      EntityRenderer* renderer =i->second;
+      if (renderer->IsDirty()) {
+        renderer->PrepareRendering();
+        updated=true;
+      }
+      renderer->VA().SetOpacity(opacity_);
+    }
+    if (updated) {
+      this->CacheBoundingBox();
     }
-    renderer->VA().SetOpacity(opacity_);
-  }
-  if (updated) {
-    this->CacheBoundingBox();
   }
   return updated;
 }
 
 void Entity::CustomPreRenderGL(bool update)
 {
-  if (update) {
+  if (update || needs_update_) {
     this->UpdateIfNeeded();
     RefreshVA();
+    needs_update_=false;
   }
 }
 
diff --git a/modules/gfx/src/entity.hh b/modules/gfx/src/entity.hh
index 0200b592b..a97192d39 100644
--- a/modules/gfx/src/entity.hh
+++ b/modules/gfx/src/entity.hh
@@ -311,6 +311,7 @@ private:
   bool blur_;
   float blurf1_;
   float blurf2_;
+  bool needs_update_;
 };
 
 
diff --git a/modules/gfx/src/gfx_object.cc b/modules/gfx/src/gfx_object.cc
index cc09ada77..8a45e784b 100644
--- a/modules/gfx/src/gfx_object.cc
+++ b/modules/gfx/src/gfx_object.cc
@@ -58,7 +58,11 @@ GfxObj::GfxObj(const String& name):
   opacity_(1.0),
   smoothf_(0.0),
   outline_flag_(false),
+#if defined (__APPLE__)
+  outline_mode_(2),
+#else
   outline_mode_(1),
+#endif
   c_ops_(),
   labels_(),
   use_occlusion_(false)
diff --git a/modules/gfx/src/vertex_array.cc b/modules/gfx/src/vertex_array.cc
index 4e42c234b..da764f97f 100644
--- a/modules/gfx/src/vertex_array.cc
+++ b/modules/gfx/src/vertex_array.cc
@@ -437,7 +437,7 @@ void IndexedVertexArray::RenderGL()
     glCullFace(GL_FRONT);
     glEnable(GL_CULL_FACE);
     glShadeModel(GL_FLAT);
-    if(outline_mode_==2) {
+    if(outline_mode_==1) {
       glCallList(outline_mat_dlist_);
       glEnable(GL_POLYGON_OFFSET_LINE);
       glEnable(GL_POLYGON_OFFSET_POINT);
@@ -447,7 +447,7 @@ void IndexedVertexArray::RenderGL()
       glEnable(GL_LINE_SMOOTH);
       glDisable(GL_POINT_SMOOTH); // kills selfx fragment shader if enabled
       glDisable(GL_POLYGON_SMOOTH);
-    } else if(outline_mode_==1) {
+    } else if(outline_mode_==2) {
       glCallList(outline_mat_dlist_);
       glEnable(GL_POLYGON_OFFSET_LINE);
       glPolygonOffset(10.0,1.0);
-- 
GitLab