Panda3D
eggAttributes.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggAttributes.I
10  * @author drose
11  * @date 1999-01-16
12  */
13 
14 /**
15  *
16  */
17 INLINE bool EggAttributes::
18 has_normal() const {
19  return (_flags & F_has_normal) != 0;
20 }
21 
22 /**
23  *
24  */
25 INLINE const LNormald &EggAttributes::
26 get_normal() const {
27  nassertr(has_normal(), _normal);
28  return _normal;
29 }
30 
31 /**
32  *
33  */
34 INLINE void EggAttributes::
35 set_normal(const LNormald &normal) {
36  _normal = normal;
37  _flags |= F_has_normal;
38 }
39 
40 /**
41  *
42  */
43 INLINE void EggAttributes::
44 clear_normal() {
45  _flags &= ~F_has_normal;
46 }
47 
48 /**
49  * Returns true if this normal matches that of the other EggAttributes object,
50  * include the morph list.
51  */
52 INLINE bool EggAttributes::
53 matches_normal(const EggAttributes &other) const {
54  if (((_flags ^ other._flags) & F_has_normal) != 0) {
55  return false;
56  }
57  if (!has_normal()) {
58  return true;
59  }
60  return (get_normal() == other.get_normal() &&
61  _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold) == 0);
62 }
63 
64 /**
65  * Sets this normal to be the same as the other's, include morphs. If the
66  * other has no normal, this clears the normal.
67  */
68 INLINE void EggAttributes::
69 copy_normal(const EggAttributes &other) {
70  if (!other.has_normal()) {
71  clear_normal();
72  } else {
73  set_normal(other.get_normal());
74  _dnormals = other._dnormals;
75  }
76 }
77 
78 /**
79  *
80  */
81 INLINE bool EggAttributes::
82 has_color() const {
83  return (_flags & F_has_color) != 0;
84 }
85 
86 /**
87  * Returns the color set on this particular attribute. If there is no color
88  * set, returns white.
89  */
90 INLINE LColor EggAttributes::
91 get_color() const {
92  if (has_color()) {
93  return _color;
94  } else {
95  return LColor(1.0, 1.0, 1.0, 1.0);
96  }
97 }
98 
99 /**
100  *
101  */
102 INLINE void EggAttributes::
103 set_color(const LColor &color) {
104  _color = color;
105  _flags |= F_has_color;
106 }
107 
108 /**
109  *
110  */
111 INLINE void EggAttributes::
112 clear_color() {
113  _flags &= ~F_has_color;
114 }
115 
116 /**
117  * Returns true if this color matches that of the other EggAttributes object,
118  * include the morph list.
119  */
120 INLINE bool EggAttributes::
121 matches_color(const EggAttributes &other) const {
122  if (((_flags ^ other._flags) & F_has_color) != 0) {
123  return false;
124  }
125  if (!has_color()) {
126  return true;
127  }
128  return (get_color() == other.get_color() &&
129  _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold) == 0);
130 }
131 
132 /**
133  * Sets this color to be the same as the other's, include morphs. If the
134  * other has no color, this clears the color.
135  */
136 INLINE void EggAttributes::
137 copy_color(const EggAttributes &other) {
138  if (!other.has_color()) {
139  clear_color();
140  } else {
141  set_color(other.get_color());
142  _drgbas = other._drgbas;
143  }
144 }
145 
146 /**
147  * An ordering operator to compare two vertices for sorting order. This
148  * imposes an arbitrary ordering useful to identify unique vertices.
149  */
150 INLINE bool EggAttributes::
151 sorts_less_than(const EggAttributes &other) const {
152  return compare_to(other) < 0;
153 }
void copy_normal(const EggAttributes &other)
Sets this normal to be the same as the other's, include morphs.
Definition: eggAttributes.I:69
LColor get_color() const
Returns the color set on this particular attribute.
Definition: eggAttributes.I:91
bool matches_color(const EggAttributes &other) const
Returns true if this color matches that of the other EggAttributes object, include the morph list.
bool matches_normal(const EggAttributes &other) const
Returns true if this normal matches that of the other EggAttributes object, include the morph list.
Definition: eggAttributes.I:53
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
Definition: eggAttributes.h:33
void copy_color(const EggAttributes &other)
Sets this color to be the same as the other's, include morphs.
int compare_to(const EggMorphList< MorphType > &other, double threshold) const
compare_to() compares a different space than the operator methods, which only check the morph's name.
Definition: eggMorphList.I:83
bool sorts_less_than(const EggAttributes &other) const
An ordering operator to compare two vertices for sorting order.
int compare_to(const EggAttributes &other) const
An ordering operator to compare two vertices for sorting order.