00001 // Filename: renderAttrib.I 00002 // Created by: drose (21Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: RenderAttrib::compose 00022 // Access: Public 00023 // Description: Returns a new RenderAttrib object that represents the 00024 // composition of this attrib with the other attrib. In 00025 // most cases, this is the same as the other attrib; a 00026 // compose b produces b. Some kinds of attributes, like 00027 // a TextureTransform, for instance, might produce a new 00028 // result: a compose b produces c. 00029 //////////////////////////////////////////////////////////////////// 00030 INLINE CPT(RenderAttrib) RenderAttrib:: 00031 compose(const RenderAttrib *other) const { 00032 return compose_impl(other); 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: RenderAttrib::invert_compose 00037 // Access: Public 00038 // Description: Returns a new RenderAttrib object that represents the 00039 // composition of the inverse of this attrib with the 00040 // other attrib. In most cases, this is the same as the 00041 // other attrib; !a compose b produces b. Some kinds of 00042 // attributes, like a TextureTransform, for instance, 00043 // might produce a new result: !a compose b produces c. 00044 // 00045 // This is similar to compose() except that the source 00046 // attrib is inverted first. This is used to compute 00047 // the relative attribute for one node as viewed from 00048 // some other node, which is especially useful for 00049 // transform-type attributes. 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE CPT(RenderAttrib) RenderAttrib:: 00052 invert_compose(const RenderAttrib *other) const { 00053 return invert_compose_impl(other); 00054 } 00055 00056 //////////////////////////////////////////////////////////////////// 00057 // Function: RenderAttrib::make_default 00058 // Access: Public 00059 // Description: Returns a different (or possibly the same) 00060 // RenderAttrib pointer of the same type as this one 00061 // that corresponds to whatever the standard default 00062 // properties for render attributes of this type ought 00063 // to be. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE CPT(RenderAttrib) RenderAttrib:: 00066 make_default() const { 00067 return return_new(make_default_impl()); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: RenderAttrib::compare_to 00072 // Access: Public 00073 // Description: Provides an arbitrary ordering among all unique 00074 // RenderAttribs, so we can store the essentially 00075 // different ones in a big set and throw away the rest. 00076 // 00077 // This method is not needed outside of the RenderAttrib 00078 // class because all equivalent RenderAttrib objects are 00079 // guaranteed to share the same pointer; thus, a pointer 00080 // comparison is always sufficient. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE int RenderAttrib:: 00083 compare_to(const RenderAttrib &other) const { 00084 // First, we compare the types; if they are of different types then 00085 // they sort differently. 00086 TypeHandle type = get_type(); 00087 TypeHandle other_type = other.get_type(); 00088 if (type != other_type) { 00089 return type.get_index() - other_type.get_index(); 00090 } 00091 00092 // We only call compare_to_impl() if they have the same type. 00093 return compare_to_impl(&other); 00094 }