Browse Source

allow changes

David Rose 19 years ago
parent
commit
14690717a2

+ 44 - 0
panda/src/display/graphicsThreadingModel.I

@@ -57,6 +57,20 @@ get_cull_name() const {
   return _cull_name;
   return _cull_name;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsThreadingModel::set_cull_name
+//       Access: Published
+//  Description: Changes the name of the thread that will handle
+//               culling in this model.  This won't change any windows
+//               that were already created with this model; this only
+//               has an effect on newly-opened windows.
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsThreadingModel::
+set_cull_name(const string &cull_name) {
+  _cull_name = cull_name;
+  update_stages();
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsThreadingModel::get_cull_stage
 //     Function: GraphicsThreadingModel::get_cull_stage
 //       Access: Published
 //       Access: Published
@@ -82,6 +96,20 @@ get_draw_name() const {
   return _draw_name;
   return _draw_name;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsThreadingModel::set_draw_name
+//       Access: Published
+//  Description: Changes the name of the thread that will handle
+//               drawing in this model.  This won't change any windows
+//               that were already created with this model; this only
+//               has an effect on newly-opened windows.
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsThreadingModel::
+set_draw_name(const string &draw_name) {
+  _draw_name = draw_name;
+  update_stages();
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsThreadingModel::get_draw_stage
 //     Function: GraphicsThreadingModel::get_draw_stage
 //       Access: Published
 //       Access: Published
@@ -106,6 +134,22 @@ get_draw_stage() const {
 INLINE bool GraphicsThreadingModel::
 INLINE bool GraphicsThreadingModel::
 get_cull_sorting() const {
 get_cull_sorting() const {
   return _cull_sorting;
   return _cull_sorting;
+
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsThreadingModel::set_cull_sorting
+//       Access: Published
+//  Description: Changes the flag that indicates whether the threading
+//               model involves a separate cull pass.  This won't
+//               change any windows that were already created with
+//               this model; this only has an effect on newly-opened
+//               windows.
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsThreadingModel::
+set_cull_sorting(bool cull_sorting) {
+  _cull_sorting = cull_sorting;
+  update_stages();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 26 - 14
panda/src/display/graphicsThreadingModel.cxx

@@ -64,22 +64,9 @@ GraphicsThreadingModel(const string &model) {
     _cull_name = model.substr(start, slash - start);
     _cull_name = model.substr(start, slash - start);
     _draw_name = model.substr(slash + 1);
     _draw_name = model.substr(slash + 1);
   }
   }
-  if (_cull_name.empty()) {
-    _cull_stage = 0;
-  } else {
-    _cull_stage = 1;
-  }
-  if (!_cull_sorting || _draw_name.empty()) {
-    _draw_name = _cull_name;
-  }
 
 
-  if (_draw_name == _cull_name) {
-    _draw_stage = _cull_stage;
-  } else {
-    _draw_stage = _cull_stage + 1;
-  }
+  update_stages();
 }
 }
-  
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsThreadingModel::get_model
 //     Function: GraphicsThreadingModel::get_model
@@ -95,3 +82,28 @@ get_model() const {
     return string("-") + get_cull_name();
     return string("-") + get_cull_name();
   }
   }
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsThreadingModel::update_stages
+//       Access: Private
+//  Description: Called internally to recompute _cull_stage and
+//               _draw_stage after either name has been changed.
+////////////////////////////////////////////////////////////////////
+void GraphicsThreadingModel::
+update_stages() {
+  if (_cull_name.empty()) {
+    _cull_stage = 0;
+  } else {
+    _cull_stage = 1;
+  }
+  if (!_cull_sorting || _draw_name.empty()) {
+    _draw_name = _cull_name;
+  }
+
+  if (_draw_name == _cull_name) {
+    _draw_stage = _cull_stage;
+  } else {
+    _draw_stage = _cull_stage + 1;
+  }
+}
+  

+ 8 - 0
panda/src/display/graphicsThreadingModel.h

@@ -34,15 +34,23 @@ PUBLISHED:
   
   
   string get_model() const;
   string get_model() const;
   INLINE const string &get_cull_name() const;
   INLINE const string &get_cull_name() const;
+  INLINE void set_cull_name(const string &cull_name);
   INLINE int get_cull_stage() const;
   INLINE int get_cull_stage() const;
+
   INLINE const string &get_draw_name() const;
   INLINE const string &get_draw_name() const;
+  INLINE void set_draw_name(const string &cull_name);
   INLINE int get_draw_stage() const;
   INLINE int get_draw_stage() const;
+
   INLINE bool get_cull_sorting() const;
   INLINE bool get_cull_sorting() const;
+  INLINE void set_cull_sorting(bool cull_sorting);
  
  
   INLINE bool is_single_threaded() const;
   INLINE bool is_single_threaded() const;
   INLINE bool is_default() const;
   INLINE bool is_default() const;
   INLINE void output(ostream &out) const;
   INLINE void output(ostream &out) const;
 
 
+private:
+  void update_stages();
+
 private:
 private:
   string _cull_name;
   string _cull_name;
   int _cull_stage;
   int _cull_stage;