From 6c3a82cdb50940046ab132c85f181bd4ad323a64 Mon Sep 17 00:00:00 2001
From: Ansgar Philippsen <ansgar.philippsen@gmail.com>
Date: Wed, 8 May 2013 11:53:56 -0400
Subject: [PATCH] fixed broken linewidth for primlist

---
 examples/gfx/prims.py        |  8 ++++++++
 modules/gfx/src/prim_list.cc | 12 ++++++++++++
 modules/gfx/src/prim_list.hh |  1 +
 3 files changed, 21 insertions(+)
 create mode 100644 examples/gfx/prims.py

diff --git a/examples/gfx/prims.py b/examples/gfx/prims.py
new file mode 100644
index 000000000..637f6a6b7
--- /dev/null
+++ b/examples/gfx/prims.py
@@ -0,0 +1,8 @@
+p=gfx.PrimList("p")
+p.AddLine(geom.Vec3(0,0,0),geom.Vec3(5,0,0))
+p.AddLine(geom.Vec3(0,0,0),geom.Vec3(0,5,0))
+p.AddLine(geom.Vec3(0,0,0),geom.Vec3(0,0,5))
+p.SetColor(gfx.YELLOW)
+scene.Add(p)
+p.SetLineWidth(5)
+p.SetAALines(True)
diff --git a/modules/gfx/src/prim_list.cc b/modules/gfx/src/prim_list.cc
index 0c8589ea2..0b06442fd 100644
--- a/modules/gfx/src/prim_list.cc
+++ b/modules/gfx/src/prim_list.cc
@@ -143,6 +143,16 @@ geom::Vec3 PrimList::GetCenter() const
   return cen;
 }
 
+void PrimList::SetLineWidth(float w)
+{
+  GfxObj::SetLineWidth(w);
+  va_.SetLineWidth(line_width_);
+  simple_va_.SetLineWidth(line_width_);
+  for(std::vector<IndexedVertexArray>::iterator it=vas_.begin();it!=vas_.end();++it) {
+    it->SetLineWidth(line_width_);
+  }
+}
+
 void PrimList::OnRenderModeChange()
 {
   // noop
@@ -323,6 +333,7 @@ void PrimList::prep_simple_va()
   simple_va_.SetTwoSided(true);
   simple_va_.SetAALines(GetAALines());
   simple_va_.SetOpacity(GetOpacity());
+  simple_va_.SetLineWidth(line_width_);
 
   for(SpherePrimList::const_iterator it=points_.begin();it!=points_.end();++it) {
     simple_va_.Add(it->position,geom::Vec3(),it->color);
@@ -342,6 +353,7 @@ void PrimList::prep_va()
   va_.SetCullFace(true);
   va_.SetColorMaterial(true);
   va_.SetMode(0x4);
+  va_.SetLineWidth(line_width_);
 
   for(SpherePrimList::const_iterator it=spheres_.begin();it!=spheres_.end();++it) {
     va_.AddSphere(SpherePrim(it->position, it->radius, it->color), 
diff --git a/modules/gfx/src/prim_list.hh b/modules/gfx/src/prim_list.hh
index 80eabe333..1b6b97969 100644
--- a/modules/gfx/src/prim_list.hh
+++ b/modules/gfx/src/prim_list.hh
@@ -74,6 +74,7 @@ class DLLEXPORT_OST_GFX PrimList: public GfxObj
 
   virtual void OnRenderModeChange();
 
+  virtual void SetLineWidth(float w);
   /// \brief clear all prims
   void Clear();
 
-- 
GitLab