Browse Source

add_light, remove_light

David Rose 24 years ago
parent
commit
17ba5c39b0
2 changed files with 34 additions and 0 deletions
  1. 31 0
      panda/src/pgraph/lightAttrib.I
  2. 3 0
      panda/src/pgraph/lightAttrib.h

+ 31 - 0
panda/src/pgraph/lightAttrib.I

@@ -65,6 +65,37 @@ get_light(int n) const {
   return _lights[n];
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: LightAttrib::add_light
+//       Access: Published
+//  Description: Returns a new LightAttrib, just like this one, but
+//               with the indicated light added to the list of lights.
+////////////////////////////////////////////////////////////////////
+INLINE CPT(RenderAttrib) LightAttrib::
+add_light(Light *light) const {
+  if (_operation == O_remove) {  
+    return compose(make(O_remove, light));
+  } else {
+    return compose(make(O_add, light));
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LightAttrib::remove_light
+//       Access: Published
+//  Description: Returns a new LightAttrib, just like this one, but
+//               with the indicated light removed from the list of
+//               lights.
+////////////////////////////////////////////////////////////////////
+INLINE CPT(RenderAttrib) LightAttrib::
+remove_light(Light *light) const {
+  if (_operation == O_remove) {  
+    return compose(make(O_add, light));
+  } else {
+    return compose(make(O_remove, light));
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: LightAttrib::is_identity
 //       Access: Published

+ 3 - 0
panda/src/pgraph/lightAttrib.h

@@ -61,6 +61,9 @@ PUBLISHED:
   INLINE Light *get_light(int n) const;
   bool has_light(Light *light) const;
 
+  INLINE CPT(RenderAttrib) add_light(Light *light) const;
+  INLINE CPT(RenderAttrib) remove_light(Light *light) const;
+
   INLINE bool is_identity() const;
   INLINE bool is_all_off() const;